# Routing to custom defined controller method

**URL:** <https://www.ruby-forum.com/t/routing-to-custom-defined-controller-method/164814>\
**Category:** Rails\
**Created:** [April 6, 2009, 9:42am UTC](https://www.ruby-forum.com/t/routing-to-custom-defined-controller-method/164814 "2009-04-06T09:42:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cesar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@Cesar](https://www.ruby-forum.com/u/Cesar)\
**Post date:** [April 6, 2009, 9:42am UTC](https://www.ruby-forum.com/t/routing-to-custom-defined-controller-method/164814/1 "2009-04-06T09:42:45Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Cesar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@Cesar](https://www.ruby-forum.com/u/Cesar)\
**Post date:** [April 6, 2009, 10:04am UTC](https://www.ruby-forum.com/t/routing-to-custom-defined-controller-method/164814/2 "2009-04-06T10:04:27Z")

</div>

On Apr 5, 11:32 pm, Cesar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

> **[Rails Routing from the Outside In — Ruby on Rails Guides](https://guides.rubyonrails.org/routing.html)**
>
> Rails Routing from the Outside InThis guide covers the user-facing features of Rails routing.After reading this guide, you will know: How to interpret the code in config/routes.rb. How to construct your own routes, using either the preferred...

)

Fred
