我刚刚将一个项目移动到另一台服务器,并且似乎遇到了与Ruby 1.9.2以来可用的新的新哈希参数相关的问题。当我运行rails s
时,我收到以下错误
Exiting
/usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load': /var/www/myapp/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError) ...sion_store :cookie_store, key: '_myapp_session'
^
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:556
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:555:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/engine.rb:555
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/myapp/config/environment.rb:5
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /var/www/myapp/config.ru:4
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/builder.rb:51:in `initialize'
from /var/www/myapp/config.ru:1:in `new'
from /var/www/myapp/config.ru:1
错误引用以下行
Myapp::Application.config.session_store :cookie_store, key: '_myapp_session'
我真的不认为上面的代码行是问题所在。如果我删除键:'_ myapp_session'或将其恢复为Ruby 1.8.X样式我只是得到下一个哈希参数错误。
我移动到的服务器最初在服务器上运行了Ruby 1.8.7。我已将ruby更新为1.9.3。当我运行ruby -v
时,我得到ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
我不确定为什么我仍然遇到哈希问题。有没有人遇到过类似的问题?
答案 0 :(得分:2)
您可能需要检查路径,它似乎正在使用1.8 ruby树中的可执行文件。升级时,您可能需要重新安装宝石..这种情况是rvm是安装ruby的首选方式的一个原因。
答案 1 :(得分:1)
你应该发布你怀疑有罪的代码,用这么少的线索很难回答。
关于新样式的一个问题是,如果散列中的所有键都是符号,则只能使用它,这可能是问题所在。