1

我正在使用 Rails 服务器,没有任何问题 ubuntu 12.04。但我想在终端上的控制台尝试一些方法,我使用

rails console

命令。但它不起作用。输出在这里:

/var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load': /home/mehmet/www/tutorial/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_tutorial_session'
                              ^
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:588
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `send'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/mehmet/www/tutorial/config/environment.rb:5
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:103:in `require'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:40
    from script/rails:6:in `require'
    from script/rails:6
mehmet@vefanet:~/www/tutorial$ rails console
/var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load': /home/mehmet/www/tutorial/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_tutorial_session'
                              ^
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /var/lib/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:588
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `send'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/mehmet/www/tutorial/config/environment.rb:5
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:103:in `require'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
    from /var/lib/gems/1.8/gems/railties-3.2.9/lib/rails/commands.rb:40
    from script/rails:6:in `require'
    from script/rails:6

那么,你有什么想法吗?我该怎么办?

4

1 回答 1

3

看起来有问题的文件使用了 ruby​​ 1.9 引入的新哈希语法。看起来您正在使用 ruby​​ 1.8 运行该应用程序。

1.) 您可以安装和使用 ruby​​ 1.9 2.) 您可以更改文件的哈希语法。Rails 3.2.9 应该与 ruby​​ 1.8.7 一起运行,所以希望这是唯一有问题的地方。

哈希语法的区别是:

1.9

{key: 'value'}

1.8

{:key => 'value'}
于 2013-01-06T13:50:18.390 回答