2

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.

Community
  • 1
  • 1
George Shaw
  • 1,771
  • 1
  • 18
  • 32
  • Does your Rails app run locally? (You're going to develop locally, so get used to running the app locally.) – Jordan Running Oct 21 '11 at 13:48
  • Have you tried running `heroku logs` to check the log file on Heroku? – Alex Peattie Oct 21 '11 at 14:51
  • No, I'm learning :-). Running them to failure I get these: 2011-10-21T16:24:30+00:00 app[web.1]: cache: [GET /] miss 2011-10-21T16:24:30+00:00 heroku[nginx]: 24.4.2.21 - - [21/Oct/2011:09:24:30 -0700] "GET / HTTP/1.1" 200 1864 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)" gws-demo-app.heroku.com 2011-10-21T16:24:30+00:00 app[web.1]: cache: [GET /assets/rails.png] miss2011-10-21T16:24:30+00:00 heroku[router]: GET gws-demo-app.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=25ms status=404 bytes=728 ...continued – George Shaw Oct 21 '11 at 16:34
  • 2011-10-21T16:24:30+00:00 heroku[nginx]: 24.4.2.21 - - [21/Oct/2011:09:24:30 -0700] "GET /assets/rails.png HTTP/1.1" 404 728 "http://gws-demo-app.heroku.com/" " Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)" gws-demo-app.heroku.com 2011-10-21T16:24:36+00:00 app[web.1]: cache: [GET /users] miss 2011-10-21T16:24:36+00:00 heroku[router]: GET gws-demo-app.heroku.com/users dyno=web.1 queue=0 wait=0ms service=126ms status=500 bytes=728 one last line... – George Shaw Oct 21 '11 at 16:40
  • 2011-10-21T16:24:36+00:00 heroku[nginx]: 24.4.2.21 - - [21/Oct/2011:09:24:36 -0700] "GET /users HTTP/1.1" 500 728 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Window s NT 6.0; WOW64; Trident/5.0)" gws-demo-app.heroku.com I don't know how to read these, but I don't see "error" anywhere. – George Shaw Oct 21 '11 at 16:40

3 Answers3

3

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.

Christian Specht
  • 35,843
  • 15
  • 128
  • 182
MO12
  • 31
  • 4
0

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

Community
  • 1
  • 1
  • Thanks @zed_0xff for the highlighting the syntax in the post. After reviewing, it looks like I had modified my Gemfile too: `gem 'sqlite3', '1.3.4', :group => :development` – rgunderson Dec 16 '11 at 19:52
  • 1
    Thanks, but no success. I still get the same error when running the precompile locally. When I do a `git push heroku` it does a precompile and appears to complete with no errors. Note that I've finished the tutorial and have the same issue with the completed sample_app, `gws-sample-app.heroku.com` – George Shaw Dec 16 '11 at 19:53
0

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.

Community
  • 1
  • 1
George Shaw
  • 1,771
  • 1
  • 18
  • 32