Wednesday, October 14, 2009

Acts_as_Authenticated Plugin in Rails

In ruby on rails environment by using this plugin we can built a login system with all most all the function, with in few minitues. Follow the steps in bellow

1.Install the plugin: script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated
2. Generate the user and account models: script/generate authenticated user account
3. Rake the DB to add the users table: rake db:migrate
4. Finally, add this line to application.rb controller so you can use the gem: include AuthenticatedSystem

Type Url -http://localhost:3000/account/signup
Then you can see the sign up page
Type- http://localhost:3000/account/login
then you can see tha login page

To protect pages so they require login, simply add this line to the beginning of your controller class:

before_filter :login_required

If you want to exclude certain views from requiring authentication, just add the list of exceptions:

before_filter :login_required, :except => [:show]

def show
# view stuff ...
end

No comments:

Post a Comment