SyntaxError on the welcome to rails screen using Pow - ruby-on-rails

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!

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.

As you can read in the Pow User's Manual under point 2.3 you have to add a .rvmrc into the root directory of your project with the content rvm 1.9.2.
Then it should work!

I resolved this by deleting the ~/.rvm directory and reinstalling RVM.

Related

Getting Rails 1.1.2 server running on Mac script/server

So I'm a rails developer familiar with Rails 3 and 4. I'm taking on a Rails 1.1.2 project, and the first problem I'm having is getting the server running.
I'd really love some help figuring out what I'm missing setting up the environment. When I run script/server, I get:
-bash: script/server: /Users/michael/.rvm/gems/ruby-1.9.3-p545: bad interpreter: Permission denied
This is after noting that at the top of the script/server file, there's an opportunity to define the location of the ruby install with a ruby comment:
#!/Users/michael/.rvm/gems/ruby-1.9.3-p545
At least, this is how I understand it. What should this comment point to? Does this look correct? I've installed ruby 1.9.3 using rvm and installed rails V 1.1.2 through sudo gem install rails. Everything seemed to work fine.
Is this some kind of bash permissions issue? I really don't understand what's going on. Any help would be appreciated!
I believe a rails project that old will require Ruby 1.8.7, so you should start with an older version of Ruby just to be sure. Once you get it running with the older ruby version, you can try 1.9 again, but trying it with 1.8.7 should help you out a bit. Your shebang should be able to do this though:
#!/usr/bin/env ruby
It needs the path of the ruby interpreter, which can be obtained dynamically via the above line.

failed rake db:migrate

When i typed: sudo rake db:migrate
I got:
rake aborted !
/home/trace/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end...sion_store :cookie_store, key: '_trace_session'
Note that my version of ruby is:
ruby -v: 1.9.2p312
And that in my bashrc i have:
rvm use 1.9.2-final#rails310.
session_store.rb:
# Be sure to restart your server when you modify this file.
Trace::Application.config.session_store :cookie_store, key: '_trace_session'
Thanks in advance
The problem is that you're using sudo... this is causing the system's Ruby (probably 1.8.7) to be used instead of your rvm Ruby. Just get rid of the sudo and run this:
rake db:migrate
Whenver rvm in used, sudo is skipped unless we need to install system libraries if the gem installation fails which installed in system. All the local gems are used from the gemset or from the global if no gemset is specified.Just have look over a tutorial on web to make things easier in rvm. solution suggested by dylan makes things clear.

Default an EngineYard Jruby instance to 1.9.2

I have a Rails app I am trying to test in Jruby on Engineyard. I can get it locally working when i switch ruby version in rvm to 1.9.2 (jruby) However when on engineyard a deploy fails:
syntax error, unexpected ':'
I solved this error locally using 1.9.2 export JRUBY_OPTS=--1.9 I have tried this on engineayrd but i am still getting the same error.
Does anyone know how to set EngineYard to default to 1.9.2 not ruby-1.8.7-p330?
Any help is greatly appreciate
Try putting the following in /home/deploy/.jrubyrc:
compat.version=1.9

Syntax error when creating a Rails model

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?
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.
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
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
I was able to resolve this by adding an .rvmrc file to my application.
echo "rvm ruby-2.0.0#rails32 --create" > .rvmrc
I resolved this by deleting my ~/.rvm directory and reinstalling RVM.
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

getting error in generator active_admin:resource -> key: '_manager_session'

i want to resolve this error, anyone please, this error is about syntax error in session_store.rb file, at attachment in pastie:
http://pastie.org/2681282
It looks like you're trying to use Ruby 1.9-style Hash syntax (key: value) in Ruby 1.8. Either upgrade to Ruby 1.9 or change your code to use the Hash syntax supported in Ruby 1.8, i.e. :key => '_manager_session'.
Checkout my answer here:
Mac OSX Snow Leopard - Rails error: Session_store.rb

Resources