Rails 1.2: Getting Started
Jan 25, 2007It was fairly significant last Friday when Rails 1.2 was made official. There’s been a lot of hype building for this release, enough so that many people have been running the Edge releases of Rails just so they can play with ActiveResource. So for those of you who aren’t quite sure where to start, here’s a step by step process on how to get a basic Rails 1.2 project up and running.
From the command line:
1. Install Rails 1.2
sudo gem install rails --include-dependencies
2. Create A New Project
rails MyRailsApp
cd MyRailsApp
3. Scaffold Resource
script/generate scaffold_resource Widget title:string description:string
The scaffolding is much improved from previous releases, and it’s not something that needs to be shunned anymore. It still isn’t something that you just want to include in production untouched, but it’s a much better base to start from now.
Now open up your project in your favorite editor.
4. The Database
The generated database.yml file comes ready for MySQL, but since we’re just going to use this as a test application lets keep things simple and use Sqlite instead. If you don’t have Sqlite on your machine it’s a fairly easy to get on your machine, and I wrote step by step instructions awhile ago.
Change the development section of your database.yml file to this:
development: adapter: sqlite3 database: db/dev.db
5. Fire Up Mongrel
mongrel_rails start -d
Now you just have to open a browser, http://0.0.0.0:3000/widgets, and you’re set. You should see your empty scaffolding and can start creating some widgets. Make sure you look at all the auto-generated code, as it’s a really good way to get familiar with the new Rails 1.2 things.