0

I am using Ruby version 1.9 and Rails version 3.2

I have included this in my gemfile (as instructed by Micheal Hartl in his book)

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

My repo is running perfectly in my local server and I can successfully deploy it on Heroku as well ( as in, it doesn't show any error) but when I try to open it on Heroku, it says some error has occured.

Heroku link:

Link to heroku application which isn't working

My Github Repo:

Github Repository

How do I get my rails application to run on Heroku?

EDIT:

Here is the Heroku log :

2014-01-09T14:29:19.456148+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
2014-01-09T14:29:19.456148+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2014-01-09T14:29:19.456383+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
2014-01-09T14:29:19.456383+00:00 app[web.1]:    script/rails:6:in `require'
2014-01-09T14:29:19.456383+00:00 app[web.1]:    script/rails:6:in `<main>'
2014-01-09T14:29:19.456383+00:00 app[web.1]: [2014-01-09 14:29:19] INFO  going to shutdown ...
2014-01-09T14:29:19.456148+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
2014-01-09T14:29:19.456148+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
2014-01-09T14:29:19.456383+00:00 app[web.1]: [2014-01-09 14:29:19] INFO  WEBrick::HTTPServer#start done.
2014-01-09T14:29:19.456383+00:00 app[web.1]: Exiting
2014-01-09T14:29:20.728995+00:00 heroku[web.1]: Process exited with status 143
2014-01-09T14:29:21.335721+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 30327`
2014-01-09T14:29:26.583076+00:00 app[web.1]: [2014-01-09 14:29:26] INFO  WEBrick::HTTPServer#start: pid=2 port=30327
2014-01-09T14:29:26.582958+00:00 app[web.1]: [2014-01-09 14:29:26] INFO  ruby 2.0.0 (2013-11-22) [x86_64-linux]
2014-01-09T14:29:26.582958+00:00 app[web.1]: [2014-01-09 14:29:26] INFO  WEBrick 1.3.1
2014-01-09T14:29:26.780187+00:00 heroku[web.1]: State changed from starting to up
2014-01-09T14:29:31.141689+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:30327
2014-01-09T14:29:31.141689+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-01-09T14:29:31.141689+00:00 app[web.1]: Started GET "/" for 115.253.102.219 at 2014-01-09 14:29:31 +0000
2014-01-09T14:29:31.141689+00:00 app[web.1]: => Booting WEBrick
2014-01-09T14:29:31.141689+00:00 app[web.1]: => Call with -d to detach
2014-01-09T14:29:31.417971+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2014-01-09T14:29:31.565602+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-01-09T14:29:31.573778+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (2.0ms)
2014-01-09T14:29:31.577581+00:00 heroku[router]: at=info method=GET path=/ host=khems.herokuapp.com fwd="115.253.102.219" dyno=web.1 connect=2ms service=461ms status=500 bytes=643
2014-01-09T14:29:31.582759+00:00 app[web.1]:     3:  <![endif]-->

2014-01-09T14:29:31.582759+00:00 app[web.1]:     4:  <%= stylesheet_link_tag 'blueprint/screen' , :media => 'screen' %>

2014-01-09T14:29:31.579472+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (2.5ms)
2014-01-09T14:29:31.582759+00:00 app[web.1]:     1: <!--[if lt IE 9]>

2014-01-09T14:29:31.582759+00:00 app[web.1]:     6:  <!--[if lt IE 8]>

2014-01-09T14:29:31.582759+00:00 app[web.1]:     7:  <%= stylesheet_link_tag 'blueprint/ie' %>

2014-01-09T14:29:31.582759+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb__3247735197042063147_70327889246660'
2014-01-09T14:29:31.582985+00:00 app[web.1]:   app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__3301566358678381586_70327889035920'
2014-01-09T14:29:31.582985+00:00 app[web.1]: 
2014-01-09T14:29:31.582985+00:00 app[web.1]: 
2014-01-09T14:29:31.582759+00:00 app[web.1]: 
2014-01-09T14:29:31.582759+00:00 app[web.1]:     2:  <script src = "http://html5shiv.googlecode.com/svn/truck/html5.js"></script>

2014-01-09T14:29:31.579878+00:00 app[web.1]: Completed 500 Internal Server Error in 14ms
2014-01-09T14:29:31.582759+00:00 app[web.1]: ActionView::Template::Error (blueprint/screen.css isn't precompiled):
2014-01-09T14:29:31.582759+00:00 app[web.1]:     5:  <%= stylesheet_link_tag 'blueprint/print' , :media=> 'print' %>

2014-01-09T14:29:34.837363+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=khems.herokuapp.com fwd="115.253.102.219" dyno=web.1 connect=1ms service=32ms status=200 bytes=0
2014-01-09T14:29:16.041585+00:00 heroku[api]: Deploy 34c58d2 by piyushkhemka123@gmail.com
2014-01-09T14:29:16.188472+00:00 heroku[api]: Release v13 created by piyushkhemka123@gmail.com
2014-01-09T14:31:30.246363+00:00 app[web.1]: Started GET "/" for 115.253.102.219 at 2014-01-09 14:31:30 +0000
2014-01-09T14:31:30.252668+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-01-09T14:31:30.254018+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (0.4ms)
2014-01-09T14:31:30.261045+00:00 app[web.1]: ActionView::Template::Error (blueprint/screen.css isn't precompiled):
2014-01-09T14:31:30.261045+00:00 app[web.1]:     2:  <script src = "http://html5shiv.googlecode.com/svn/truck/html5.js"></script>

2014-01-09T14:31:30.261045+00:00 app[web.1]:     3:  <![endif]-->

2014-01-09T14:31:30.261045+00:00 app[web.1]:     7:  <%= stylesheet_link_tag 'blueprint/ie' %>

2014-01-09T14:31:30.261045+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb__3247735197042063147_70327889246660'
2014-01-09T14:31:30.261220+00:00 app[web.1]:   app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__3301566358678381586_70327889035920'
2014-01-09T14:31:30.262525+00:00 heroku[router]: at=info method=GET path=/ host=khems.herokuapp.com fwd="115.253.102.219" dyno=web.1 connect=5ms service=30ms status=500 bytes=643
2014-01-09T14:31:30.258672+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.9ms)
2014-01-09T14:31:30.261045+00:00 app[web.1]: 
2014-01-09T14:31:30.258971+00:00 app[web.1]: Completed 500 Internal Server Error in 6ms
2014-01-09T14:31:30.261045+00:00 app[web.1]:     1: <!--[if lt IE 9]>

2014-01-09T14:31:30.261045+00:00 app[web.1]:     4:  <%= stylesheet_link_tag 'blueprint/screen' , :media => 'screen' %>

2014-01-09T14:31:30.261045+00:00 app[web.1]:     5:  <%= stylesheet_link_tag 'blueprint/print' , :media=> 'print' %>

2014-01-09T14:31:30.261220+00:00 app[web.1]: 
2014-01-09T14:31:30.261220+00:00 app[web.1]: 
2014-01-09T14:31:30.261045+00:00 app[web.1]:     6:  <!--[if lt IE 8]>

2014-01-09T14:38:53.893957+00:00 heroku[router]: at=info method=GET path=/robots.txt host=khems.herokuapp.com fwd="50.17.151.94" dyno=web.1 connect=2ms service=32ms status=200 bytes=204
2014-01-09T14:38:53.935144+00:00 app[web.1]: Started GET "/" for 50.17.151.94 at 2014-01-09 14:38:53 +0000
2014-01-09T14:38:53.947809+00:00 app[web.1]: Processing by PagesController#home as */*
2014-01-09T14:38:53.952314+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (1.0ms)
2014-01-09T14:38:53.954570+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2014-01-09T14:38:53.954280+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (1.6ms)
2014-01-09T14:38:53.956529+00:00 app[web.1]: ActionView::Template::Error (blueprint/screen.css isn't precompiled):
2014-01-09T14:38:53.956529+00:00 app[web.1]:     2:  <script src = "http://html5shiv.googlecode.com/svn/truck/html5.js"></script>

2014-01-09T14:38:53.956529+00:00 app[web.1]:     3:  <![endif]-->

2014-01-09T14:38:53.956529+00:00 app[web.1]:     1: <!--[if lt IE 9]>

2014-01-09T14:38:53.956529+00:00 app[web.1]:     4:  <%= stylesheet_link_tag 'blueprint/screen' , :media => 'screen' %>

2014-01-09T14:38:53.956529+00:00 app[web.1]:     5:  <%= stylesheet_link_tag 'blueprint/print' , :media=> 'print' %>

2014-01-09T14:38:53.956529+00:00 app[web.1]: 
2014-01-09T14:38:53.956529+00:00 app[web.1]:     6:  <!--[if lt IE 8]>

2014-01-09T14:38:53.956529+00:00 app[web.1]:     7:  <%= stylesheet_link_tag 'blueprint/ie' %>

2014-01-09T14:38:53.956529+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb__3247735197042063147_70327889246660'
2014-01-09T14:38:53.956710+00:00 app[web.1]:   app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__3301566358678381586_70327889035920'
2014-01-09T14:38:53.956710+00:00 app[web.1]: 
2014-01-09T14:38:53.956710+00:00 app[web.1]: 
2014-01-09T14:38:53.963277+00:00 heroku[router]: at=info method=GET path=/ host=khems.herokuapp.com fwd="50.17.151.94" dyno=web.1 connect=7ms service=36ms status=500 bytes=643
2014-01-09T14:39:54.023115+00:00 app[web.1]: Started GET "/" for 115.253.102.219 at 2014-01-09 14:39:54 +0000
2014-01-09T14:39:54.029462+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-01-09T14:39:54.030376+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (0.3ms)
2014-01-09T14:39:54.031387+00:00 app[web.1]:   Rendered layouts/_stylesheets.html.erb (0.6ms)
2014-01-09T14:39:54.031484+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms
2014-01-09T14:39:54.033858+00:00 app[web.1]: 
2014-01-09T14:39:54.033858+00:00 app[web.1]: ActionView::Template::Error (blueprint/screen.css isn't precompiled):
2014-01-09T14:39:54.033858+00:00 app[web.1]:     1: <!--[if lt IE 9]>

2014-01-09T14:39:54.033858+00:00 app[web.1]:     2:  <script src = "http://html5shiv.googlecode.com/svn/truck/html5.js"></script>

2014-01-09T14:39:54.033858+00:00 app[web.1]:     3:  <![endif]-->

2014-01-09T14:39:54.033858+00:00 app[web.1]:     4:  <%= stylesheet_link_tag 'blueprint/screen' , :media => 'screen' %>

2014-01-09T14:39:54.033858+00:00 app[web.1]:     5:  <%= stylesheet_link_tag 'blueprint/print' , :media=> 'print' %>

2014-01-09T14:39:54.034039+00:00 app[web.1]:   app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__3301566358678381586_70327889035920'
2014-01-09T14:39:54.033858+00:00 app[web.1]:     6:  <!--[if lt IE 8]>

2014-01-09T14:39:54.033858+00:00 app[web.1]:     7:  <%= stylesheet_link_tag 'blueprint/ie' %>

2014-01-09T14:39:54.033858+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:4:in `_app_views_layouts__stylesheets_html_erb__3247735197042063147_70327889246660'
2014-01-09T14:39:54.034039+00:00 app[web.1]: 
2014-01-09T14:39:54.034039+00:00 app[web.1]: 
2014-01-09T14:39:54.033750+00:00 heroku[router]: at=info method=GET path=/ host=khems.herokuapp.com fwd="115.253.102.219" dyno=web.1 connect=1ms service=21ms status=500 bytes=643

Here is the assets compile log

  E:/RailsInstaller/Ruby1.9.3/bin/ruby.exe E:/RailsInstaller/Ruby1.9.3/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

Compiled jquery.js  (16ms)  (pid 13464)
Compiled jquery_ujs.js  (1ms)  (pid 13464)
Compiled pages.js  (198ms)  (pid 13464)
Compiled users.js  (205ms)  (pid 13464)
Compiled application.js  (494ms)  (pid 13464)
Compiled custom.css  (0ms)  (pid 13464)
Compiled pages.css  (12ms)  (pid 13464)
Compiled users.css  (4ms)  (pid 13464)
Compiled application.css  (62ms)  (pid 13464)
Compiled jquery.js  (21ms)  (pid 11524)
Compiled jquery_ujs.js  (0ms)  (pid 11524)
Compiled pages.js  (335ms)  (pid 11524)
Compiled users.js  (312ms)  (pid 11524)
Compiled application.js  (773ms)  (pid 11524)
Compiled custom.css  (0ms)  (pid 11524)
Compiled pages.css  (10ms)  (pid 11524)
Compiled users.css  (16ms)  (pid 11524)
Compiled application.css  (69ms)  (pid 11524)
jmromer
  • 2,212
  • 1
  • 12
  • 24
Piyush
  • 606
  • 4
  • 16
  • 38
  • 1
    Did you migrate db and precompile assets? – zrl3dx Jan 09 '14 at 13:52
  • You can use heroku logs in your console to see what is not working. – Pierre Jan 09 '14 at 13:53
  • What is your question? – sawa Jan 09 '14 at 13:56
  • My application doesn't have any database yet. I tried precompiling but it shows me an error saying that : You have activated Rake 10.1.1 but your Gemfile requires 10.1.0 . I went through my gemfile and couldn't see any mention of rake anywhere. – Piyush Jan 09 '14 at 13:56
  • fix rake to version `10.1.1` in your **Gemfle** as : `gem 'rake', '10.1.1'`, then try to run `bundle install` locally – Малъ Скрылевъ Jan 09 '14 at 14:02
  • additionally, why did you close the *pg* gem under `:production` condition? – Малъ Скрылевъ Jan 09 '14 at 14:04
  • I updated my Gemfile. I migrated my db and precompiled my assets and I am still getting the same error. The page on Heroku just says that something went wrong and doesn't display anything. – Piyush Jan 09 '14 at 14:14
  • @majioa : I am learning how to code in Ruby on Rails right now. This is how it was referred in Micheal Hartl's tutorial. – Piyush Jan 09 '14 at 14:15
  • Did you run `bundle install` locally, before pushing to heroku? – Малъ Скрылевъ Jan 09 '14 at 14:18
  • Yes after updating the gemfile, I executed the `bundle install` command, followed by `git add .`, followed by committing the change and pushing it. Finally I executed the `git push heroku master` command. – Piyush Jan 09 '14 at 14:19
  • 1
    I saw your **Gemfile**, please issue `bundle install --without=test,development` in your local console – Малъ Скрылевъ Jan 09 '14 at 14:20
  • 1
    So you firstly do `git add .`, and then `bundle install`? Do as follows. 1. `bundle install --without=test,development` and make sure that it is passed without errors, 2. issue `bundle install`, 3. issue `git add .` ; 4. issue `git add -f Gemfile.lock` 5. commit changes 6. issue push to heroku. – Малъ Скрылевъ Jan 09 '14 at 14:22
  • @majioa : I followed your instructions step by step. I did it twice, First without precompiling the assets and then with compiling the assets, it is still not working. – Piyush Jan 09 '14 at 14:32
  • @majioa : Updated the original post with the log – Piyush Jan 09 '14 at 14:45
  • I don't see any Gemfile ro bundle errors, only asset errors. Could you compile in assets also? – Малъ Скрылевъ Jan 09 '14 at 15:00
  • @majioa : Updated the original question with assets log – Piyush Jan 09 '14 at 15:21
  • 1
    I don't see the `You have activated Rake 10.1.1 but your Gemfile requires 10.1.0` error anyway... caould you show heroku push log? – Малъ Скрылевъ Jan 09 '14 at 15:24
  • 1
    The precompile error mentions `screen.css` but I don't see that in the list of compiled assets in the compilation log. It's possible that CSS file isn't getting included in precompilation, and you may not notice this locally if you're compiling assets in development. Hence, it breaks in production environment, but not elsewhere. Check your `config/environments/` folder, and compare the various `config.assets` options for development vs. production. – jefflunt Jan 09 '14 at 15:34
  • I updated the gem file. Hence it is not showing the rake error anymore. @jefflunt : The development file :`config.assets.compress = false config.assets.debug = true` and the production file: `config.assets.compress = true config.assets.compile = false config.assets.digest = true` – Piyush Jan 09 '14 at 16:36
  • 1
    @SuperTed's answer should take care of the blueprint stylesheet problem. – jefflunt Jan 09 '14 at 16:45

1 Answers1

2

First move your blueprint directory into assets/stylesheets directory.

Add into environments/production.rb

config.assets.precompile += %w( blueprint/screen.css blueprint/print.css blueprint/ie.css custom.css)

you can precompiling your assets localy if you want :

bundle exec rake assets:precompile RAILS_ENV=production
Yann VERY
  • 1,819
  • 14
  • 11
  • Ahh...finally it worked. Thank you so much :) Two questions for future reference: 1>Am I supposed to put the blueprint/bootstrap or any other css framework into the assets/stylesheets directory instead of the public folder as suggested by the tutorial? 2> Do I need to precompile my assets each time before I push them to heroku? – Piyush Jan 09 '14 at 17:03
  • Yes, put all your css/javascripts into your assets directory is a good practice. take a look at http://guides.rubyonrails.org/asset_pipeline.html for a better use of asset pipeline. – Yann VERY Jan 09 '14 at 17:09
  • In production.rb config.assets.compile is set to false, so you need to precompile before push on heroku. – Yann VERY Jan 09 '14 at 17:16
  • If I were to make the value true, would it work without precompiling or lead to issues elsewhere? – Piyush Jan 09 '14 at 18:46