Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a login form in Rails 3?

I have a User model (with all validators and properties defined) and a UsersController. For the controller, I have a login action and a login.html.erb view file. How do I create a simple login form that validates the username and password?

like image 721
Mike Avatar asked Feb 25 '11 04:02

Mike


1 Answers

I'd strongly recommend you take a look at using either Authlogic or Devise to do your login. You can find a number of tutorials that will help guide you through setting up either service. I like the Railscasts on the two subjects:

  • http://railscasts.com/episodes/209-introducing-devise
  • http://railscasts.com/episodes/160-authlogic

If you want to roll your own authentication, you can. Railscasts also provides a tutorial on doing that:

  • http://railscasts.com/episodes/250-authentication-from-scratch
like image 148
Kevin Sylvestre Avatar answered Oct 16 '22 18:10

Kevin Sylvestre