Rails 3.1 Deployment to Heroku Error

给你一囗甜甜゛ 提交于 2019-11-29 02:45:53

问题


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'


回答1:


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.




回答2:


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



回答3:


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


来源:https://stackoverflow.com/questions/6222673/rails-3-1-deployment-to-heroku-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!