Syntax error when creating a Rails model

后端 未结 6 1587
旧时难觅i
旧时难觅i 2020-12-19 20:10

I am creating Car model in Rails 3 by using command:

rails generate model Car name:string id_str:string

but I got the error:



        
6条回答
  •  感动是毒
    2020-12-19 20:15

    This error usually happens when you are trying to use the Ruby 1.9.2 Hash syntax with Ruby < 1.9.

    In Ruby 1.9.2 the following code works perfectly

    Myapp::Application.config.session_store :cookie_store, key: '_myapp_session'
    

    while in Ruby < 1.9 you must use

    Myapp::Application.config.session_store :cookie_store, :key => '_myapp_session'
    

    This is strange, because your stack trace references Ruby 1.9.2. Are you sure you are running the generator with Ruby 1.9.2?

    In any case, you can convert your session_store.rb file to the hash-rocket syntax. If it works, it means you are not using Ruby 1.9.2 and you pasted an invalid error message.

提交回复
热议问题