Tuesday, October 28, 2008

Installing restful_authentication and acts_as_state_machine (aasm) as plugins

Here are the steps I took to install restful_authentication with acts_as_state_machine (using the new aasm gem) as plugins.

Started in the rails home directory of the app.

Installed aasm gem as a plugin:

script/plugin install git://github.com/rubyist/aasm.git

(thanks to Erik on Rails for the above)

Installed restful authentication:
git submodule add \
git://github.com/technoweenie/restful-authentication.git \

I use capistrano so I also added the following to my config/deploy.rb file
set :git_enable_submodules, 1

Created a lib directory in the app home directory:
mkdir lib

Called the restful authentication generator. Fyi, instead of user, I use person as the name of my model for people:
./script/generate authenticated person sessions --include-activation --aasm

Then I did the post-generate steps, following some of the instructions at github. Some of the steps enumerated in the docs seem to be taken care of as part of the generate call now.

In config/routes.rb, I did a find/replace on peoples (incorrect plural) replacing all with people (correct plural) and added the activate route. In the end my routes.rb looked like this:
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'people', :action => 'create'
map.signup '/signup', :controller => 'people', :action => 'new'
map.activate '/activate/:activation_code', :controller => 'people',
:action => 'activate', :activation_code => nil
map.resources :people, :member => { :suspend => :put,
:unsuspend => :put,
:purge => :delete }

In config/environment.rb, I added:
config.active_record.observers = :person_observer

So I can use before filters in my controllers, I modified app/controllers/application.rb to include AuthenticatedSystem:
class ApplicationController < ActionController::Base
helper :all
include AuthenticatedSystem

I adjusted the language in app/models/person_mailer.rb, especially replacing the YOURSITE references to be the URL of my site:
@body[:url] =

1 comment:

  1. Casino at Wynn in Las Vegas: Review, Hotel, Restaurant, & More
    This luxurious resort features an outdoor pool 성남 출장안마 and 의왕 출장안마 a variety of restaurants, 제주도 출장안마 bars, restaurants 사이트 추천 and a casino. Location: 8.3 mi Rating: 천안 출장마사지 4 · ‎Review by KTNV