I am a Newbie on Ruby on Rails, and I've had some issues with the deployment of RoR applications.
EDIT 1: Trying to narrow down the question a bit. I am uncertain whether my issues with the deployment of my rudimentary Ruby apps are results of my erroneous setup and coding or conflicts in the version of Ruby on Rails I am currently using.
Rephrasing question: What version of Ruby on Rails should I use? Being a newbie to the frameworks, I just want my deployment process to be as smooth as possible. If 3.2 is the official download (as of jan 20, 2012) is it safe to use, and should I then use the latest stable version of Ruby (1.9.3-p0)? What about gems mentioned in books and writings? Should I always use the latest one?
Old discussion
I am following Ruby On Rails Tutorial. Following the instructions in the book I try to deploy on Heroku, but with no luck. Printouts from the Heroku log gives:
2012-01-22T18:26:09+00:00 app[web.1]: Started GET "/pages/about" for 90.231.141.39 at
2012-01-22T18:26:09+00:00 app[web.1]: cache: [GET /pages/about] miss
2012-01-22T18:26:09+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished
(ActiveRecord::ConnectionNotEstablished):
This application does not use any database at this point (only presenting static pages). So to me the ActiveRecord error comes as no suprise. Uncertain though if this is the root to the problem. I first thought that this issue was realted to Heroku, since my rails server
deployment worked fine, but the I found the rails server -e production
command to run the rails server in production environment. Under Rails 3.1.3 this renders the page correctly, but I still get the following error message in the server log:
sample_app$ rails server -e production
=> Booting WEBrick
=> Rails 3.1.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:07:28] INFO WEBrick 1.3.1
[2012-01-22 23:07:28] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:07:28] INFO WEBrick::HTTPServer#start: pid=57161 port=3000
cache: [GET /] miss
cache: [GET /pages/about] miss
Started GET "/pages/about" for 127.0.0.1 at 2012-01-22 23:09:50 +0100
Processing by PagesController#about as HTML
Rendered pages/about.html.erb within layouts/application (2.0ms)
Completed 200 OK in 24ms (Views: 24.2ms | ActiveRecord: 0.0ms)
cache: [GET /assets/application-cd728f3a08415c27ca2e753d30091c74.css] miss
It seems to me that there is some kind of routing issue. But my lack of knowledge and experience with RoR makes me a lame duck in the search for the actual error.
Upgrading to Rails 3.2.0 made the issue even worse. I made a sample app for Rails 3.2 basically with:
rails new test_app
Entered the "test_app" folder and ran rails server -e production
(using Ruby 1.9.3-p0
). This time the default Ruby on Rails index page was not even rendered. The server log gives me:
heroku_test$ rails server -e production
=> Booting WEBrick
=> Rails 3.2.0 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:19:07] INFO WEBrick 1.3.1
[2012-01-22 23:19:07] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:19:07] INFO WEBrick::HTTPServer#start: pid=63242 port=3000
cache: [GET /] miss
So, it seems in all cases like I have some issues with my routing or my caching or wathever.
These are my specs:
System specs: Mac OS X Lion 10.7.2
Ruby: 1.9.3-p0
Rails: 3.1.3 (and also 3.2.0 release the other day)
I am very aware that these specs are not what Ruby on Rails Tutorial propose. The RoR tutorial is written with the follow Specs in mind:
Ruby: 1.9.2 (or 1.8.7)
Rails: 3.0.11
In chapter 13, Hartl explains the difference with Rails 3.1.x and sports an upgrade guide for the sample_app. I've skimmed through this chapter (since I am stuck at chapter 3) but have been unable to find a remedy to my problems.
What is my question really?
How do I deploy a RoR app to production for a version of RoR that runs on my system?
Related links and sources I've browsed so far, apart from the regular pages on RoR.org and Heroku.com:
cache: [GET /] miss? dalli gem, memcached, rails 3.1, nginx, unicorn production environment
How does one load a CSS framework in Rails 3.1?