Search code examples
ruby-on-railscustom-routes

Adding custom route to routes file Rails 2


I want to be able to do the following:

change_pass_user_path(usuario)

in a "link_to" (for example).

where "change_pass" is the name of my action inside de "user" controller.

I already added this:

map.resources :users

to my routes file. (so I'm already able to do things like: edit_user_path)

I already tried:

map.resources :users do
    get 'change_pass'
  end

but it returns this error:

undefined method `get' for main:Object (NoMethodError)

How can I do that?

Thx


Solution

  • Try this,

    map.resources :users, :member => { :change_pass => :get }