I reading Rails Tutorial and created a Sample_App.
My code is available here: https://github.com/namic/sample_app
Heroku is running the app here: http://afternoon-mist-7865.herokuapp.com/
It works in test, development and production environment on my laptop, but Heroku denies me the joy with "We're sorry, but something went wrong."
Any suggestions?
Solution:
Add to Gemfile:
group :production do
gem 'pg'
end
And remember to run bundle install without production, if you dont want postgresql local:
bundle install --without production
Check the logs and make sure you ran the migrations on heroku.
heroku run rake db:migrate
Related
I have this configuration in my Gemfile:
group :test do
# ...
gem "shoulda-matchers", :git => "git://github.com/watu/shoulda-matchers.git", :branch => "do_not_load_minitest"
end
which works fine locally, but when I push to Heroku, when I try to run rake db:migrate, I get this error:
git://github.com/watu/shoulda-matchers.git (at do_not_load_minitest) is not checked out. Please run bundle install
Indeed I don't see it in the output of bundle install being run on Heroku, maybe because it's on the test group and Heroku is not installing the test group. But then, why is it complaining when I run rake db:migrate? should it run in staging env?
I tried switching to the http url and all I got is the same error with another URL:
https://github.com/watu/shoulda-matchers.git (at do_not_load_minitest) is not checked out. Please run bundle install
Moving the line outside the :test group workarounded the problem. What's the proper solution?
If you don't really need that gem (since it is in :test group), you can add this configuration to your app:
heroku config:add BUNDLE_WITHOUT="development:test" --app <your_app>
im having this issue when i try to deploy my ruby on rails application to heroku, i check different posts here, because i saw this issue before but i couldnt fix it.
when i try to run:
$ heroku rake db:migrate
I get a lot of these ones: DEPRECATION WARNING:
and then:
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
I tried to change my Gemfile with 'pg' and my group :assets do to :production, i know im missing something but i could'nt figured out what.
Some ideas?
Also when I go to the app url, I get this:
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
Thanks in advance for any suggest and help!!!
You have to use Postgres on Heroku, you can't use sqlite3 because Heroku prohibits you from saving to the file system. So add the pg gem to your production bundle and re-deploy then your migrations should run.
Answer here is simple, add the following production in your gemfile as:
group :production do
gem 'pg'
end
Your local machine won't work with this production, so we now have to bundle it by ignoring PostgreSQL gem which can be done as:
bundle install --without production
After this, try heroku rake db:migrate. Must work.
Good luck
I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.
I've got a basic app that I'm trying to deploy to Heroku. I can push it to Heroku with git and it shows the default Rails welcome page, but when I try to access any subpages, (pages that work when I deploy on a local server with rails server) I get "something went wrong" messages.
I pulled up the log and I'm get 500 responses from the server and lots of ActiveRecord::ConnectionNotEstablished messages which seems to be an issue connecting to the database.
Further, when I tried to run heroku rake db:migrate, I get the following errors
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
Per the suggestion above, I did add gem 'pg' to the Gemfile After running gem install pg and then bundle install. Also, I tried gem install activerecord-postgresql-adapter (on Windows) and get
ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in a
ny repository
ERROR: Possible alternatives: activerecord-jdbcpostgresql-adapter, activerecord
-postgis-adapter, activerecord-jdbcmssql-adapter, activerecord-jdbcmysql-adapter
, activerecord-postgresql-cursors
From the suggestion of the book that I'm reading, I ran heroku db:push and it competed without error, but it didn't solve the problem of the pages not rendering once the app is push to Heroku.
update: I've tried installing the activerecord-jdbcpostgresql-adapter as suggested as a possible alternative. I updated the Gemfile with
group :production, :staging do
gem 'pg'
end
and the database.yml file with
production:
adapter: jdbcpostgresql
and when I heroku rake db:migrate, it still gives me the message telling me to install postgresql adapter
If heroku rake db:migrate runs without error, then your database connection info is correct. It's likely that there's another error preventing the page from rendering correctly. If you tail your heroku logs while making a request, are you still getting the same database error? I suspect that you'll find it's a different error that you'll need to fix.
I am currently making my way through the Ruby on Rails tutorial over at http://ruby.railstutorial.org/ and I am trying to migrate the demo_app database to heroku.
heroku rake db:migrate
rake aborted!
unable to open database file
I have read on other stackoverflow posts that some people fixed this by entering
group :production, :staging do
gem "pg"
end
group :development, :test do
gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
in the gemfile. I also entered it into my gemfile and then deleted my old gemfile.lock and redid my bundle install AND rake db:migrate command. I am still receiving the same error.
I am obviously brand new to ruby, rails and heroku but I understand that the problem seems to be that I am using sqlite locally and postgresql in production (on heroku). Do I now have to install this postgresql onto my machine and then RE-migrate the DB? I am afraid I will not be able to get much more out of the tutorials (or ruby on rails itself) if I cannot use heroku.
Kill it!
I was having the same problem and found no solutions. I think something we are doing in those tutorials is leading us to mangle the database.yml file that heroku generates.
I ended up destroying my heroku app
heroku destroy
and then creating a new one, pushing a fresh copy, and running
heroku create
git push heroku master
heroku rakedb:migrate
This time everything worked fine! Just make sure you have the pg gem in your gemfile for production
group :production do
gem "pg"
end
and add config/database.yml to your .gitignore file too for good measure.
or if it's working ok locally do a heroku db:push to magically put your local sqlite DB into Heroku's postgresql db.
I always work with the same DB platform locally just so I don't run into any differences (usually only when you start doing DB specific SQL) so I run Postgresql locally too.
Had the same problem... with Heroku interface... ran:
heroku rake db:migrate --trace
and found the problem to be with faker, not being found...Since 'faker' in our Gemfile is loaded in the development group, I loaded it in the production group as well.
saved Gemfile
bundle install
git add .
git commit -m "fixed faker"
git push
git heroku push
heroku rake db:migrate
heroku rake db:populate
now everything works...the QUESTION, now is what to do with 100 users on my production site?
At least I can continue with Hartl's tutorial!!