Restful_authentication: getting error when trying to login


After downloading the restful_authentication plugin, I have the
following in my config/routes.rb file:

map.signup ‘/signup’, :controller => ‘users’, :action => ‘new’
map.login ‘/login’, :controller => ‘session’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘session’, :action => ‘destroy’

and here is my login form:

<%= form_tag(‘/login’, :method => :post) %>

Login: <%= text_field_tag("login", '') %>
Password: <%= password_field_tag("password", '') %>
<%= submit_tag("Login") %>
<%= end_form_tag %>

but after logging in, I’m redirected to “” and I
get this error:

Unknown action
No action responded to show

Oh, and this is the session controller I have …

class SessionController < ApplicationController

Be sure to include AuthenticationSystem in Application Controller

include AuthenticatedSystem

render new.rhtml

def new
redirect_to :action => ‘create’

def create
self.current_user = User.authenticate(params[:login],
if logged_in?
if params[:remember_me] == “1”
cookies[:auth_token] = { :value =>
self.current_user.remember_token , :expires =>
self.current_user.remember_token_expires_at }
flash[:notice] = “Logged in successfully”
render :controller => ‘register’, :action => ‘start’

Why am I getting this error? - Dave

On Jan 23, 11:50 am, “[email protected]
[email protected] wrote:

but after logging in, I’m redirected to “” and I
get this error:

Unknown action
No action responded to show

I encountered the same error messages when I used the
restful_authentication plugin and tried to add new actions to my users
controller. When I looked at the server log files, I saw this error

Parameters: {“action”=>“show”, “id”=>“newaction”,
ActionController::UnknownAction (No action responded to show):

I received these error messages because, per the installation
instructions for restful_authentication, I had added this line of code
to my routes.rb file:

map.resources :users, :member => { :suspend => :put, :unsuspend
=> :put, :purge => :delete }

The call to ActionController::resources here defines the users class
as a RESTful resource:

which means (among other things) that by default the class only
supports six actions - new, create, show, edit, update and destroy.
Each of these actions uses one of the four basic HTTP verbs - GET,

If we go back to this line from routes.rb:

map.resources :users, :member => { :suspend => :put, :unsuspend
=> :put, :purge => :delete }

it appears that our controller should support not only the standard
six actions but also a ‘suspend’, ‘unsuspend’ and ‘purge’ action. If
you type ‘rake routes’, you should see routes for these actions. (If
you don’t, make certain that there is only one “map.resources :users”
line in routes.rb) The routes that rake prints for these non-RESTful
actions should look something like this:

suspend_user PUT /users/:id/suspend
{:controller=>“users”, :action=>“suspend”}
formatted_suspend_user PUT /users/:id/suspend.:format
{:controller=>“users”, :action=>“suspend”}

Note the :id parameter - these actions all operate on an existing
object (which, of course, has an ID). But this won’t work for the
‘create’ action you said you wanted to add to your controller, since
you want to create a new object, not modify an existing one. In this
case, you should use :collection instead of :member, like so:

map.resources :users,
:member => { :suspend => :put, :unsuspend => :put, :purge
=> :delete },
:collection => { :create => :get}

The API documentation for ActionController::resources has more
information. Another useful source of information about RESTful
interfaces is the “Advanced Rails Recipes” Beta Book:

Pragmatic Bookshelf: By Developers, For Developers

The book has a chapter entitled “Adding Your Own REST Actions (Or
Not)” that provides more detail about how to add custom actions to a
RESTful resource that was created by ActionController::Resources.

If you are just interested in renaming the ‘new’ action to ‘create’
instead of making up new types of actions, then you could try playing
around with these modifications to routes.rb:

map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘sessions’, :action =>

These two examples are printed out when you run the ‘authenticated’
generator. If you didn’t save the output of the generator when you
first ran it, just look in this file:


I suspect you don’t want to completely get rid of the ‘new’ action,
since this will break some of the RESTful behavior.

Hope this helps,