1

ubuntu 12.04で問題なくRailsサーバーを使用しています。しかし、端末のコンソールでいくつかの方法を試してみたいので、使用します

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 に答える