SyntaxError on the welcome to rails screen using Pow

Dave picture Dave · Aug 20, 2011 · Viewed 8.2k times · Source

I have just set up a new project which displays all the correct info in the about your applications environment window when on http://localhost:3000/ but when I run it at http://egg.dev/ I get:

SyntaxError: /users/davidhall/work/egg/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
...sion_store :cookie_store, key: '_egg_session'
                              ^

I'm sure I had this problem earlier, which was due to me using rails 3.1 with ruby 1.8.7, the problem resolved when I used ruby 1.9.2. Now I'm getting when using 1.9.2 too.

Thanks for any help its much appreciated!

Answer

Yuanfei Zhu picture Yuanfei Zhu · Sep 7, 2011

The Problem is that, there is a new-style hash argument available in Ruby1.9.2 but unavailable in Ruby1.8.7 which is

key: value  # only available in 1.9.2
    ||
:key => value # available in 1.8.7 and 1.9.2

so, with a less effort, you can just modify the syntax to the one that 1.8.7 recognized.