Hello Rails 3 World
Today marks the first beta release of the coming version of Rails, version 3.0 and I figured it’d be fun revisiting that post.
So, this is a step by step tutorial to getting over the first hurdle: Creating a “hello world” application in Ruby on Rails. This should work assuming you already have Rails 3 installed and running on your system:
$ rails hello
$ cd hello
$ rails generate controller hello
Open the file config/routes.rb. Almost at the bottom (line #57) is this line:
# match ':controller(/:action(/:id(.:format)))'
Remove the # in front so the line looks like:
- Create a file named index.html.erb in app/views/hello containing the text ‘Hello world’.
$ rails server
- Navigate to http://localhost:3000/hello in your browser and be greeted by your friendly application: “Hello world”.
PS: http://localhost:3000/ is (still) a lot prettier “Hello world”-ish page.
PPS: Note that the Rails 3 example above actually has a step more than the Rails 1 ditto. This comes from the fact that Rails 3 doesn’t build a default route for you.
- Ruby: 1.8.7
- Rails: 3.0.0.beta