0

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?

rails 3 tutorial: No route matches [GET] “/”

Rails 3.1 on Heroku Cedar

Community
  • 1
  • 1
jollyCocoa
  • 691
  • 7
  • 20
  • You deployment seems to have worked, and `about.html.erb` is rendering just fine(as evidenced by `Rendered pages/about.html.erb within layouts/application (2.0ms)`). What is the real problem? Are you seeing an error message about the database not found when you visit the url for `about`? It is unclear from your question. – Zabba Jan 22 '12 at 23:17
  • A cache miss isn't an error message, nor does it say "error" anywhere. And you said it rendered properly (under 3.1). What's the actual issue? – Dave Newton Jan 22 '12 at 23:20
  • You have described no "serious issues," and it looks like it's working the way it should. If you really want to know "how to deploy to production," there are hundreds of questions here and HOWTOs on the internet for that. As it stands: too general. – Eric Jan 22 '12 at 23:58
  • Hmmm... I guessed this might be to general. A normal problem when diving into a new set of tools. I'll try to narrow it down, edit and rephrase... – jollyCocoa Jan 23 '12 at 07:47
  • @Zabba: I got presented with a 404 - page does not exits message. However, I realize I might be to unspecific to get the right answer. I'll try to figure out a better formulated question. – jollyCocoa Jan 23 '12 at 08:13

2 Answers2

1

@jollyCocoa, the error you got when deploying to Heroku was caused by not having the database set up. Even if you're not using the database, if you configure the database connection anyways, it will fix this error. If you are starting with RoR, though, and just want something to experiment with, don't try deploying to Heroku at this point. Just start with a very simple application running locally, even just the "skeleton" application generated by "rails new", and make changes one small step at a time, checking at each step that the app is still working. If you get stuck and can't figure out how to get a certain feature working, you can post a more specific question.

Alex D
  • 29,755
  • 7
  • 80
  • 126
  • I realize my question was a bit to unspecific. Would you argue that I should skip deployment altogehter at this point in favor of learning the frameworks in the development environment? I wish not to end up in a situation where I've learned the frameworks in the development environment and when I get to deployment I've completely misunderstood some rudimentary concept... – jollyCocoa Jan 23 '12 at 08:42
  • Yes, you would be better to just work locally at this point. When you get to deployment, you will need to learn a few new things, but the concepts are all the same. – Alex D Jan 23 '12 at 09:20
  • Great! Well, back to the books then... – jollyCocoa Jan 23 '12 at 10:14
1

Now that the question has changed:

"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 you are learning from a book or tutorial, use the same version as the examples in that book/tutorial.

"What about gems mentioned in books and writings? Should I always use the latest one?"

Most gems have dependencies on other gems, so the exact version you use will often depend on those dependencies. Sometimes you may even discover a bug in one version, so you switch to another version to remedy the problem. Or again, if you are following a book/tutorial which uses a certain version, you may want to use the same version (at least while you are working through the tutorial). If, though, you have no good reason to use an old version, then generally you should use the newest one.

Have you learned how to use Bundler? It allows you to control the exact versions of each gem which you want to use.

Alex D
  • 29,755
  • 7
  • 80
  • 126