Hello all, I have a main model Article, which is subclassed by several others like so: --- class Music < Article class RecordReview < Music; end class Interview < Music; end end class Film < Article class Review < Film; end class Interview < Film; end end ...etc --- Doing it this way I can simply call Music.all, or Music::RecordReview.all etc to find relevant articles. For simplicity I''ve decided to use only one controller ArticlesController. My URL schema is like this: --- ''/music'' ''/music/record_reviews'' ''/music/record_reviews/1'' ''/music/record_reviews/new'' ''/music/record_reviews/1/edit'' ''/film'' ''/film/reviews'' ...etc --- So - my question is - does anybody know a clean way to define this in routes.rb, bearing in mind that all requests need to be passed to the ArticlesController, which then needs to determine which type of article we''re currently requesting. Right now i''m just doing something like this: --- map.connect '':section/:subsection/:id'', :controller => ''articles'', :action => ''show'' ..etc --- and then I use a before_filter to determine the type from the :section and :subsection params - which works - but I then don''t get any of the url/path helpers generated doing a map.resources so things are getting a bit messy. Thanks in advance --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you name the route you would... like: map.music '':section/:subsection/:id'', :controller =>music'', :action => ''show'' then you could use music_url (:action=>''whatever'', :section=>''section'', :subsection=>''subsection'', :id=>1) On Dec 16, 3:22 am, coxy <3co...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello all, > > I have a main model Article, which is subclassed by several others > like so: > > --- > class Music < Article > class RecordReview < Music; end > class Interview < Music; end > end > class Film < Article > class Review < Film; end > class Interview < Film; end > end > ...etc > --- > > Doing it this way I can simply call Music.all, or > Music::RecordReview.all etc to find relevant articles. For simplicity > I''ve decided to use only one controller ArticlesController. My URL > schema is like this: > > --- > ''/music'' > ''/music/record_reviews'' > ''/music/record_reviews/1'' > ''/music/record_reviews/new'' > ''/music/record_reviews/1/edit'' > ''/film'' > ''/film/reviews'' > ...etc > --- > > So - my question is - does anybody know a clean way to define this in > routes.rb, bearing in mind that all requests need to be passed to the > ArticlesController, which then needs to determine which type of > article we''re currently requesting. > > Right now i''m just doing something like this: > > --- > map.connect '':section/:subsection/:id'', :controller => > ''articles'', :action => ''show'' > ..etc > --- > > and then I use a before_filter to determine the type from the :section > and :subsection params - which works - but I then don''t get any of the > url/path helpers generated doing a map.resources so things are getting > a bit messy. > > Thanks in advance--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Wally. Think this could work... On Dec 16, 6:01 pm, Wally Valters <deepsk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you name the route you would... > > like: > map.music '':section/:subsection/:id'', :controller =>music'', :action > => ''show'' > > then you could use > music_url > (:action=>''whatever'', :section=>''section'', :subsection=>''subsection'', :id=>1) > > On Dec 16, 3:22 am, coxy <3co...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello all, > > > I have a main model Article, which is subclassed by several others > > like so: > > > --- > > class Music < Article > > class RecordReview < Music; end > > class Interview < Music; end > > end > > class Film < Article > > class Review < Film; end > > class Interview < Film; end > > end > > ...etc > > --- > > > Doing it this way I can simply call Music.all, or > > Music::RecordReview.all etc to find relevant articles. For simplicity > > I''ve decided to use only one controller ArticlesController. My URL > > schema is like this: > > > --- > > ''/music'' > > ''/music/record_reviews'' > > ''/music/record_reviews/1'' > > ''/music/record_reviews/new'' > > ''/music/record_reviews/1/edit'' > > ''/film'' > > ''/film/reviews'' > > ...etc > > --- > > > So - my question is - does anybody know a clean way to define this in > > routes.rb, bearing in mind that all requests need to be passed to the > > ArticlesController, which then needs to determine which type of > > article we''re currently requesting. > > > Right now i''m just doing something like this: > > > --- > > map.connect '':section/:subsection/:id'', :controller => > > ''articles'', :action => ''show'' > > ..etc > > --- > > > and then I use a before_filter to determine the type from the :section > > and :subsection params - which works - but I then don''t get any of the > > url/path helpers generated doing a map.resources so things are getting > > a bit messy. > > > Thanks in advance--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---