Routing to custom defined controller method

Hi, I’m developing my first rails project in Netbeans, with rails 2.1,
I used scaffold to generate my models, views and controllers.
The problem I’m having is that when I define a new method inside a
controller i can not access it using a “normal” url like /controller/
action
Instead, it can only be accessed by using a /controller/action/id kind
of url. If i use the /controler/action url it goes to the “show”
controller and throws an error.

Example: if I define this test1 method in users controllers It can
only be accesed by /users/test1/someid
instead of my desired /users/test1
class UsersController < ApplicationController

def test1
flash[:notice] = “Entre a login”
end
#here go all other scaffolded methods
end

I think it must have something to do with my routing, which is
configured like this…

ActionController::Routing::Routes.draw do |map|
map.resources :users
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
end

Please someone help me, thanks!

On Apr 5, 11:32 pm, Cesar [email protected] wrote:

Hi, I’m developing my first rails project in Netbeans, with rails 2.1,
I used scaffold to generate my models, views and controllers.
The problem I’m having is that when I define a new method inside a
controller i can not access it using a “normal” url like /controller/
action
Instead, it can only be accessed by using a /controller/action/id kind
of url. If i use the /controler/action url it goes to the “show”
controller and throws an error.

Have a look at the :member and :collection options to map.resources
(or have a look at the routing guide

)

Fred