Update Needed: "Getting Started with Rails"

In reference to: Getting Started with Rails — Ruby on Rails Guides

At this point in the guide:

"Now if you navigate to http://localhost:3000 in your browser, you’ll see Hello, Rails"

I get a page that says:

" Routing Error

uninitialized constant WelcomeController "

To reproduce:

rails new blog cd blog bundle install rake db:create rails server rails generate controller home index app/views/home/index.html.erb -> <h1>Hello, Rails!</h1> rm public/index.html root :to => "home#index" uncommented in routes.rb

Mac OS X 10.6 Rails 3.0.1 ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] rake, version 0.8.7 Bundler version 1.0.5

Thank you, John

The guide says

“Find the line beginning with :root to, uncomment it and change it like the following:”

Note the change bit, the generated example root points to “welcome#index”. Guess you just uncommented the line.

I pretty much did the same, except I didn't bundle. I worked round the issue (something to add to the guide maybe!). Things I did to bodge:

1) I had to use the "script/server" to run ruby rails on localhost: 3000 2) I had to use the "script/generate" to generate the scaffolding 3) I had to edit "config/routes.rb" so.. map:root controller: => "home" 4) I had to manually edit the app/controller/home_controller.rb..

class HomeController < ApplicationController   def index   render "home/index"   end end

Obviously making sure app/views/home/index.html.erb exists, with the basic HTML in.

Somehow that works!

1-3) If you had to use the script/* commands then it appears that you’re using an older version of Rails, something that’s pre-3. Same goes for your routing syntax.

  1. In all versions of Rails that I’m aware of, you don’t need to render “home/index” as this is implicit.

Could you elaborate on how you installed Rails?

Thanks Ryan! :slight_smile: I have rails 2.3.5 installed. I install through gems.

Thanks for the info Ryan. This is not the topic of the original post and neither am I the original poster, so I feel a bit jump-horse-y- ish. I did a.. sudo gem update --system and all seems ok. :slight_smile:

Hey,

Good to see you managed to solve it yourself. Yes, for the guides you will need 3.0