简体   繁体   中英

Ruby 1.9+ style hash syntax doesn't work

I'm running ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] on my macbook.

Yet, when I attempt to use "new style" hashes such as:

stylesheet_link_tag "application", media: "all"

I get an error that reads "unexpected: expecting )"

I can fix this issue by replacing with the "old style" hashrockets:

stylesheet_link_tag "application", :media => "all"

I'm trying to figure out why rails isn't allowing the new style of ruby hashes. Any help would be greatly appreciated.

Sounds like rails is running under system ruby while you have RVM installed as 1.9.3 (I would guess)

Try

$ rvm --default use 1.9.3

Then reset your console and do

$ ruby -v

to double check

Try putting this in your .bash_profile (or bashrc or whatever you are using):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

After that, of course, issue the source command then:

rvm use 1.9.2
rvm info

Which should work and display all the information about the current ruby version and gemset. The new hash syntax failing because you are not actually running ruby 1.9.3. Doing "ruby -v" should confirm the problem. Given your comment above, you rvm has to be a function in order for it to work.

Also, What operating system are you running?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM