Forum: Ruby on Rails [ROUTES] [RAILS 2.3] Custom controller method fires a route error...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D1f3d779854573da0340bf53b0b625cc?d=identicon&s=25 flaubert (Guest)
on 2009-05-06 17:28
(Received via mailing list)
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...
170e2a48994775e4c298c302e6814f81?d=identicon&s=25 Starr Horne (Guest)
on 2009-05-06 17:33
(Received via mailing list)
On Wed, 6 May 2009 08:27:42 -0700 (PDT)
flaubert <aflauberts@gmail.com> 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 Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
D1f3d779854573da0340bf53b0b625cc?d=identicon&s=25 flaubert (Guest)
on 2009-05-06 17:38
(Received via mailing list)
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!
110e527af05961700d9e39285d043b62?d=identicon&s=25 Gianluca Tessarolo (Guest)
on 2009-05-06 18:00
(Received via mailing list)
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...
170e2a48994775e4c298c302e6814f81?d=identicon&s=25 Starr Horne (Guest)
on 2009-05-06 18:27
(Received via mailing list)
On Wed, 6 May 2009 08:38:07 -0700 (PDT)
flaubert <aflauberts@gmail.com> 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 Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
This topic is locked and can not be replied to.