尝试从ruby 1.8.7升级到1.9.2,同时仍然使用rails 2.3.8

时间:2012-01-06 16:31:54

标签: ruby-on-rails ruby

当我捆绑exec脚本/服务器-p3001时,我得到以下错误/ stacktrace =(

/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:142:in `module_eval': (eval):1: syntax error, unexpected '{', expecting ';' or '\n' (SyntaxError)
              def hash_for_{:build=>[:get, :post]}_templa...
                            ^
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:142:in `named_helper_module_eval'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:152:in `define_hash_access'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:136:in `block in define_named_route_methods'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:134:in `each'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:134:in `define_named_route_methods'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:85:in `add'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:318:in `add_named_route'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:33:in `named_route'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/option_merger.rb:20:in `method_missing'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:654:in `map_resource_routes'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:606:in `map_default_collection_actions'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:536:in `block in map_resource'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/core_ext/object/misc.rb:78:in `with_options'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:528:in `map_resource'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `block in resources'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `each'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `resources'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:581:in `map_has_many_associations'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:578:in `block in map_has_many_associations'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:577:in `each'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:577:in `map_has_many_associations'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:560:in `map_associations'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:529:in `block in map_resource'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/core_ext/object/misc.rb:78:in `with_options'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:528:in `map_resource'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `block in resources'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `each'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/resources.rb:447:in `resources'
    from[project directory]/config/routes.rb:45:in `block in <top (required)>'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:227:in `draw'
    from[project directory]/config/routes.rb:1:in `<top (required)>'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `block in load_with_new_constant_marking'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load_with_new_constant_marking'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:287:in `block in load_routes!'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:287:in `each'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:287:in `load_routes!'
    from [rvm-gemset-location]/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:267:in `load!'
    from [rvm-gemset-location]/gems/rails-2.3.8/lib/initializer.rb:537:in `initialize_routing'
    from [rvm-gemset-location]/gems/rails-2.3.8/lib/initializer.rb:188:in `process'
    from [rvm-gemset-location]/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
    from[project directory]/config/environment.rb:19:in `<top (required)>'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `block in require'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from [rvm-gemset-location]/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
    from[project directory]/config.ru:3:in `block in <top (required)>'
    from [rvm-gemset-location]/gems/rack-1.1.3/lib/rack/builder.rb:46:in `instance_eval'
    from [rvm-gemset-location]/gems/rack-1.1.3/lib/rack/builder.rb:46:in `initialize'
    from[project directory]/config.ru:1:in `new'
    from[project directory]/config.ru:1:in `<top (required)>'
    from [rvm-gemset-location]/gems/rails-2.3.8/lib/commands/server.rb:78:in `eval'
    from [rvm-gemset-location]/gems/rails-2.3.8/lib/commands/server.rb:78:in `<top (required)>'
    from script/server:3:in `require'
    from script/server:3:in `<main>'

我该如何解决这个问题? 我的意思是,它指向IS的语法真的很奇怪......但这在1.8.7 = \

中有效

1 个答案:

答案 0 :(得分:1)

检查语法,我遇到了类似的问题:

syntax error, unexpected '{', expecting ';' or '\n' (SyntaxError)
              def hash_for_{:create=>:post, :delete=>:pos...

我在:routes.rb文件中为:collection键而不是hash发送一个数组。所以我有这个:

:collection => [ :next => :get, :prev => :get, :sort => :post ]

并改为:

:collection => { :next => :get, :prev => :get, :sort => :post }

希望这会有所帮助......