Today I took the plunge and installed Rails 2.0.2. Notes on the Rails 2.0 release can be found here.
Here are the steps I took.
- Upgrade Ruby Gems to the latest version (in this case 1.0.1).
gem update --system
- Install Ruby on Rails 2.0.2.
gem install rails -v 2.0.2
- Install MySQL gem (as of March 5, 2008, it is version 2.7.3) and add MySQL executable to path.
gem install mysql
- Create prayer application.
rails prayer -d mysql
- Install Restful Authentication plugin.
cd prayer
ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
- Create scaffold for prayer model.
ruby script/generate scaffold Prayer title:string body:text
The first thing I noticed different about Rails 2.0 is that the scaffold now also generates the model and data migration file with title and body as columns in the prayer table. Also the format of the data migration file is slightly more compact. - Create user model with authentication. The
--include-activation
flag is to create the mailers for activation and signup notification.
ruby script/generate authenticated user sessions --include-activation
- Configure config/database.yml and then create prayer and user tables in DB.
rake db:migrate
- Configure SMTP settings.
- Modify
app/models/user_mailer.rb
, replacing the place holders with constants which you can configure with different values for different environments usingconfig/environments/development.rb
,config/environments/production.rb
. - Modify user_observer.rb to incorporate the reset and forgotten password features.
- Create scaffold for role model. Add an admin user.
ruby script/generate scaffold Role rolename:string
- Create permission model. Modify role and permission models to know about each other.
ruby script/generate model Permission
- Modify user model to use permissions.
Much of this post is based on this excellent post, Restful Authentication with all the bells and whistles. At this point I did not continue with much of the tutorial, especially with parts like password forgotten, separate account controller, etc.