Madhusudhan
Madhusudhan

Reputation: 8563

Unknown action No action responded to show

I generated a model User using scaffolding


script/generate scaffold user username:string crypted_password:string email:string active:boolean perishable_token:string persistance_token:string

Then I added a method in UsersController


def test
end

And then created a view file test.html.erb and I am printing "Hello"

So now I am trying to access localhost:3000/users/test

It throws this error


Unknown action
No action responded to show. Actions:...

In my routes.rb I am having


map.resources :users

when I see the development log its taking parameter "test" as "id", where as its an action.

any help?

Upvotes: 3

Views: 3653

Answers (1)

lwe
lwe

Reputation: 2625

You need to define the additional action, see http://guides.rubyonrails.org/routing.html#adding-more-restful-actions for more, so change the route to

map.resources :users, :collection => { :test => :get }

A helpful utility to check all routes is rake routes - btw I assume you're using Rails 2.3.x, right?

Upvotes: 4

Related Questions