Thursday, October 26, 2006

Rails RESTful Authentication Plugin Part II

1. Include the line: map.connect '/', :controller => "sessions", :action => 'index'
in routes.rb
Browse the source code you will see that after login and logout the action methods route to '/', so the above definition will load the index.rhtml for the sessions_controller

2. In the sessions_controller.rb add the following method:
def index
end
3. Create a index.rhtml file in the views/sessions directory, include the following lines in the file:

<% if flash[:notice] -%>
<%= flash[:notice] %>

<% end -%>

Now when you login or logout, you will the message "You are logged in" and "You have been logged out message".

4. You can also uncomment the code for remember me functionality in the rhtml file. This will provide a check box that allows the user to login without entering the username and password.

No comments:

Post a Comment