Reputation: 18338
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:
/home/XX/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load': /home/XX/myapp/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_myapp_session'
why?
my session_store.rb
Myapp::Application.config.session_store :cookie_store, key: '_myapp_session'
What's wrong with my session_store.rb
?
Upvotes: 3
Views: 4822
Reputation: 1
I was able to resolve this by adding an .rvmrc file to my application.
echo "rvm ruby-2.0.0@rails32 --create" > .rvmrc
Upvotes: 0
Reputation: 16084
TL;DR: uninstall then reinstall the railties gem
Long answer:
In your project directory, if you type in which rails
, what do you see? On mine, I saw /usr/bin/rails
. This gave me a clue that it's using the wrong rails
executable. If I look at my $PATH
, I can see that RVM's bin path (/Users/ramon/.rvm/gems/ruby-1.9.3-p194/bin
) did not contain the rails
file (as to how this got deleted -- I don't have a clue). That must have been why the /usr/bin/rails
got picked up by my system instead.
Looking at the Rails source, I saw that the railties
gem has the rails
bin file. I uninstalled railties (gem uninstall railties
), then reinstalled it again. Voila - which rails
shows /Users/ramon/.rvm/gems/ruby-1.9.3-p194/bin/rails
Upvotes: 1
Reputation: 673
Well through a bit of debugging and playing around, this is what I ended up doing:
for x in `gem list --no-versions`; do sudo gem uninstall $x; done
This forces all 'old' gems to be removed. I then proceeded to verify the gem environment to confirm that gem was using the correct ruby version:
sudo gem env
The error experienced is due to the fact that rails is still trying to use ruby 1.8, which causes all sorts of issues.
Once all of the above checks out properly do:
sudo gem update --system
sudo gem install rubygems-update
sudo update_rubygems
Which will make sure that you are at the latest gem version. Then:
sudo gem install rails
This will install everything you need. I ran all of the gem commands as sudo, to make sure that my root install was properly configured/setup.
Your final gem env should look something like:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.13
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-darwin10.8.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/Cellar/ruby/1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1
Upvotes: 3
Reputation: 2199
I resolved this by deleting my ~/.rvm directory and reinstalling RVM.
Upvotes: -1
Reputation: 176562
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.
Upvotes: 7
Reputation: 1212
really strange question as error is self decribing
you have some mess in this file, and missing end statement
`load': /home/XX/myapp/config/initializers/session_store.rb:3
Upvotes: -2