# \[ROUTES\] \[RAILS 2.3\] Custom controller method fires a route error

**URL:** <https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314>\
**Category:** Rails\
**Created:** [May 6, 2009, 5:28pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314 "2009-05-06T17:28:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [May 6, 2009, 5:28pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314/1 "2009-05-06T17:28:20Z")

</div>

Hi all,

I have a custom method in my controller called ‘generate’.

when requested localhost:3000/import/generate I see “Couldn’t find  
Import with ID=generate”.

How customize a route for this method?

help please…

---

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [May 6, 2009, 5:33pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314/2 "2009-05-06T17:33:01Z")

</div>

On Wed, 6 May 2009 08:27:42 -0700 (PDT)  
flaubert [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all,
> 
> I have a custom method in my controller called ‘generate’.
> 
> when requested localhost:3000/import/generate I see “Couldn’t find  
> Import with ID=generate”.
> 
> How customize a route for this method?

map.connect ‘/import/generate/’, :controller =\> ‘import’, :action =\>  
‘generate’

–  
Starr H.  
Check out my Helpdesk RailsKit: [http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)

---

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [May 6, 2009, 5:38pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314/3 "2009-05-06T17:38:52Z")

</div>

do i have to use this for any custom method that a have created?

there isn’t any dryer solution for this?

tnks for reply!

---

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [May 6, 2009, 6:27pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314/4 "2009-05-06T18:27:32Z")

</div>

On Wed, 6 May 2009 08:38:07 -0700 (PDT)  
flaubert [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> do i have to use this for any custom method that a have created?  
> there isn’t any dryer solution for this?

The dryer solution is to use map.resource & restful urls for most  
actions, and use non-restful actions sparingly.

–  
Starr H.  
Check out my Helpdesk RailsKit: [http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)

---

<div class="post-metadata">

**Author:** ![flaubert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/858c86/32.png) [@flaubert](https://www.ruby-forum.com/u/flaubert)\
**Post date:** [May 6, 2009, 6:00pm UTC](https://www.ruby-forum.com/t/routes-rails-2-3-custom-controller-method-fires-a-route-error/167314/5 "2009-05-06T18:00:36Z")

</div>

try to put into config/routes.rb:

map.connect ‘:controller/:action’

after:

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

final result:

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
map.connect ‘:controller/:action’

Hope this helps…
