I''m trying to create a restful route for a custom action and I can not
seem to get it right.
This is the code in my routes.rb
map.resources :leagues
map.resources :leagues, :collection => {:old => :get}
old is an action in my leagues controller that will retrieve and
display a list of older leagues (like index but just a different set
of data).
I''m using this generated helper method:
<%= link_to ''List older league postings'', old_leagues_url
%> I also
tried old_leagues_path
and it seems to generate the url I would expect.
http://localhost:3000/leagues/old
But when I click on the link I get this error:
Couldn''t find League with ID=old
For some reason it''s trying to ''show'' the league old.
I used rake routes and it shows what I would expect to be the correct
route:
old_leagues GET /leagues/old
{:controller=>"leagues", :action=>"old"}
formatted_old_leagues GET /leagues/old.:format
{:controller=>"leagues", :action=>"old"}
Can somebody help me out, I''m really stuck on this..
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Dec 27, 7:21 pm, Mark <m...-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org> wrote:> > This is the code in my routes.rb > map.resources :leagues > map.resources :leagues, :collection => {:old => :get}You restarted the server after changing routes.rb, right? No, of course you did. Never mind. ///ark --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What version of Rails? On Dec 28, 2007 3:10 PM, Mark Wilden <mark-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote:> > On Dec 27, 7:21pm, Mark <m...-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org> wrote: > > > > This is the code in my routes.rb > > map.resources :leagues > > map.resources :leagues, :collection => {:old => :get} > > You restarted the server after changing routes.rb, right? No, of > course you did. Never mind. > > ///ark > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mark-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org
2007-Dec-28 13:14 UTC
Re: Restful Route for a custom action
I''m using rails 2.0.2 and yes, I have restarted the server. What version of Rails? On Dec 28, 2007 3:10 PM, Mark Wilden <mark-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote: On Dec 27, 7:21pm, Mark <m...-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org> wrote:> > This is the code in my routes.rb > map.resources :leagues > map.resources :leagues, :collection => {:old => :get}You restarted the server after changing routes.rb, right? No, of course you did. Never mind. ///ark --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m using rails 2.0.2 and yes, I have restarted the server. On Dec 27, 11:53 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What version of Rails? > > On Dec 28, 2007 3:10 PM, Mark Wilden <m...-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote: > > > > > On Dec 27, 7:21pm, Mark <m...-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org> wrote: > > > > This is the code in my routes.rb > > > map.resources :leagues > > > map.resources :leagues, :collection => {:old => :get} > > > You restarted the server after changing routes.rb, right? No, of > > course you did. Never mind. > > > ///ark > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark,
The issue is that you do not need to state the routes twice.
map.resources :leagues, :collections => {:old => :get}
is all you need. It will setup the normal restful routes and the additional
"old" route. By having
the route without the collection in front of it you are overiding the
behavior of the second route.
Simply remove the first route and it should work.
--Tim
On Dec 28, 2007 8:14 AM, <mark-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org>
wrote:
> I''m using rails 2.0.2 and yes, I have restarted the server.
>
>
>
>
> What version of Rails?
>
> On Dec 28, 2007 3:10 PM, Mark Wilden
<mark-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote:
>
> >
> > On Dec 27, 7:21pm, Mark
<m...-h9LRGznmPqMAvxtiuMwx3w@public.gmane.org> wrote:
> > >
> > > This is the code in my routes.rb
> > > map.resources :leagues
> > > map.resources :leagues, :collection => {:old => :get}
> >
> > You restarted the server after changing routes.rb, right? No, of
> > course you did. Never mind.
> >
> > ///ark
> >
> >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---