即使在捆绑安装后Rails服务器也会退出

时间:2011-11-01 20:14:05

标签: ruby-on-rails

我正在尝试运行可以下载here的“Agile Web Development with Rails 4th edition”一书中的depot_a rails3.1.0示例。

我遇到各种错误,即使在调用bundle install之前运行rails server之后我也无法解密。知道如何解决这个问题吗?

感谢。

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.    
nuno@Houdini:~/workspace/depot_a$ rails server
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load': /home/nuno/workspace/depot_a/config/initializers/session_store.rb:11: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_depot_session'
                              ^
    from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
    from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /var/lib/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/engine.rb:555
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/engine.rb:554:in `each'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/engine.rb:554
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `send'
    from /var/lib/gems/1.8/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/nuno/workspace/depot_a/config/environment.rb:13
    from /home/nuno/workspace/depot_a/config.ru:4:in `require'
    from /home/nuno/workspace/depot_a/config.ru:4
    from /var/lib/gems/1.8/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
    from /var/lib/gems/1.8/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
    from /home/nuno/workspace/depot_a/config.ru:1:in `new'
    from /home/nuno/workspace/depot_a/config.ru:1

2 个答案:

答案 0 :(得分:4)

您使用的是ruby 1.8.x吗?您似乎使用1.9.x样式哈希表示法,1.8.x无法解密

而不是

hash = { a: 1, b: 2}

你应该使用:

hash = { :a => 1, :b => 2 }

问题出在config/initializers/session_store.rb:11,如果您仍然卡住,请发布此行的代码。

答案 1 :(得分:1)

如果您已按照Rails入门进行操作并使用Mac OS X Lion,请运行

rvm use --default 1.9.2
跑步前

rails server

希望有所帮助。