0

Rails を使い始めたばかりで、サーバーを 2 回目に起動するようになったのですが、次のようなエラー メッセージが表示されます。/config/initializers の Ruby ファイルも変更していません。

george@ubuntu:~/Desktop/blog$ rails server
=> Booting WEBrick
=> Rails 3.2.8 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.2.8/lib/active_support/dependencies.rb:245:in `load': /home/george/Desktop/blog/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_blog_session'
                              ^
    from /var/lib/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /var/lib/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:588
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `send'
    from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/george/Desktop/blog/config/environment.rb:5
    from /home/george/Desktop/blog/config.ru:4:in `require'
    from /home/george/Desktop/blog/config.ru:4
    from /var/lib/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /var/lib/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /home/george/Desktop/blog/config.ru:1:in `new'
    from /home/george/Desktop/blog/config.ru:1

config/initializers/session_store の内容は以下です。

# Be sure to restart your server when you modify this file.

Blog::Application.config.session_store :cookie_store, key: '_blog_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Blog::Application.config.session_store :active_record_store
4

2 に答える 2

2

Ruby バージョン 1.8 を実行しているようです。1.9 にアップグレードする必要があります。

ハッシュ構文は ruby​​ 1.8 ではサポートされていません(key: 'value'必要な場合:key => 'value')。

それができない場合は、これらすべてのハッシュを手動で変更できますが、Ruby 1.8 の Rails サポートが不足していることに注意してください。

于 2012-10-19T17:33:17.137 に答える
0

Blog::Application.config.session_store :cookie_store, :key => '_blog_session' を試してください

于 2012-10-19T17:39:28.420 に答える