dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2006-Nov-02 00:47 UTC
[ANN] inferred_routes plugin
Hi -- I''ve written a little plugin -- consisting entirely of modifications to define_url_helper in ActionController -- which will infer nested named RESTful route components from one object. For example, given a nest like this: map.resources :schools do |s| s.resources :departments do |d| d.resources :teachers end end instead of doing this: teacher_url(@school, @department, @teacher) the plugin lets you do: teacher_url(@teacher) and it infers that you really want: teacher_url(@teacher.department.school, @teacher.department, @teacher) It''s very much a "see if people like it" kind of thing. So let me know. You can get it via subversion from: http://www.risleydale.net/svn/inferred_routes/tags/0.1.0 David -- David A. Black | dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB''s Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2006-Nov-02 02:48 UTC
Re: [ANN] inferred_routes plugin
Hi -- On Wed, 1 Nov 2006, dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org wrote:> > Hi -- > > I''ve written a little plugin -- consisting entirely of modifications > to define_url_helper in ActionController -- which will infer nested > named RESTful route components from one object.I''ve made it a little less hackerly by putting the code in lib/ rather than in init.rb :-) Nothing else has changed, but if you want to have a version that''s a bit more well-behaved in its code organization, you can get: http://www.risleydale.net/svn/inferred_routes/tags/0.1.1 David -- David A. Black | dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB''s Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David, one more question before you put your sword to rest : what about polymorphic associations? map.resources :articles do |article| article.resources :comments end map.resources :photos do |photo| photo.resources :comments end In this case, comments_url(@comment) should translate to something like comments_url(@comment.commentable_id, @comment) (?? and what about the ''commentable_type) I must confess I''m a REST newbie, so I''m not sure at all REST can work with polymorphism. Alain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---