Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 Deployment to Heroku Error

I'm trying to deploy my app to Heroku, I've done this before on my Windows machine, and now I am currently using a mac.

I'm trying to use Postgresql for the first time.

I have the following in my Gemfile:

gem 'pg'

EDIT:

AndrewDavis-OSX:lunchbox ardavis$ rvm list

rvm rubies

=> ruby-1.9.2-p180 [ x86_64 ]

AndrewDavis-OSX:lunchbox ardavis$ heroku rake db:migrate
rake aborted!
/app/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
App::Application.config.session_store :cookie_store, key: '_app_session'
                                                        ^

(See full trace by running task with --trace)
(in /app)

As you can see, I am running ruby 1.9.2. And there is the error for my heroku migration.

EDIT 2:

Just created a brand new rails app using Rails 3.1.rc1. I set the gemfile to include

group :production do gem 'therubyracer-heroku', '0.8.1.pre3' gem 'pg' end

I did a quick git init, commited, then 'heroku create' and 'git push heroku master'. Those all work just fine. However the problem is when I try 'heroku rake db:migrate'. I get the same error that you see above.

TEMP FIX EDIT:

So... if I change my config/initializers/session_store.rb from

App::Application.config.session_store :cookie_store, key: '_app_session'

to

App::Application.config.session_store :cookie_store, :key => '_app_session'

and change my config/initializers/wrap_parameters.rb from

ActionController::Base.wrap_parameters format: [:json]

to

ActionController::Base.wrap_parameters :format => [:json]

Then I'm able to do 'heroku rake db:migrate' just fine. Anyone care to explain why this works locally the original way, without any modification of the colons/hashes? The original way is the generated default from doing 'rails new myApp'

like image 435
ardavis Avatar asked Jun 03 '11 03:06

ardavis


3 Answers

The Heroku stack needs to be migrated, you can run this command to do so:

heroku stack:migrate bamboo-mri-1.9.2 

I was running 1.9.2 locally, which is why it was working locally. But on Heroku, it was running 1.8.7.

like image 122
ardavis Avatar answered Oct 10 '22 10:10

ardavis


The problem is that there is a new-style hash argument available in Ruby 1.9.2 but unavailable in Ruby 1.8.7 which is:

key: value  # only available in 1.9.2 but

:key => value # available in 1.8.7 and 1.9.2
like image 27
preksha Avatar answered Oct 10 '22 10:10

preksha


This is just an additional pointer to some. If ever you are getting the same error in your development environment, on an app that was functioning just fine moments ago, check your ruby version as Preksha/Alex Kliuchnikau mentioned above.

$ ruby -v

If ruby is not set to 1.9.2 or above, you can do that with rvm

   $ rvm --default 1.9.2   (1.9.3 is what I currently use)

If it's not responding to rvm command, add rvm to your bashrc file by copying the following line in your terminal:

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" ' >> ~/.bash_profile
like image 24
sybohy Avatar answered Oct 10 '22 10:10

sybohy