Hi, With a simple STI Employee < Person, I can write in the Person view.rhtml.erb : ... link_to ''Show'', person ... and the correct controller will be call depending on the actual (concrete) type of the record. I think this is because link_to() uses polymorphic_url() internally. However, the restful helpers, such as edit_person_path() fail to choose the correct controller and always route to the Person controller. This seems inconsistent and confusing. How can I reroute edit_person_path() to take the polymorphic type into account, and route to the correct controller? Is this by design or a bug? I hope I made myself clear. Thanks, Adi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I believe this is by design. When you say link_to(text, record), a polymorphic url is constructed depending on the model. But when you say edit_person_path, you are explicitly stating that you are dealing with Person records and that no polymorphism should take place. I understand that when using STI you have a need for a polymorphic helper, but I don''t think changing the behavior of named routes (explicit or automatically generated) is a solution - it would just be the source of more confusion for others. Your cup of tea would be the edit_polymorphic_path helper, as in this example I just put up: http://pastie.org/141162 - Mislav On Jan 20, 2008 1:32 PM, adish <adishavit@gmail.com> wrote:> > Hi, > > With a simple STI Employee < Person, I can write in the Person > view.rhtml.erb : > > ... > link_to ''Show'', person > ... > > and the correct controller will be call depending on the actual > (concrete) type of the record. > I think this is because link_to() uses polymorphic_url() internally. > > However, the restful helpers, such as edit_person_path() fail to > choose the correct controller and always route to the Person > controller. This seems inconsistent and confusing. > > How can I reroute edit_person_path() to take the polymorphic type into > account, and route to the correct controller? > > Is this by design or a bug? > > I hope I made myself clear. > Thanks, > Adi > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Mislav, Excellent! Just what I needed. Thanks! I couldn''t find it in my Rails 2.0.2 installation. I need the "Simply Helpful" plugin, right? Thanks, Adi On Jan 20, 3:10 pm, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> I believe this is by design. > > When you say link_to(text, record), a polymorphic url is constructed > depending on the model. But when you say edit_person_path, you are > explicitly stating that you are dealing with Person records and that no > polymorphism should take place. > > I understand that when using STI you have a need for a polymorphic helper, > but I don''t think changing the behavior of named routes (explicit or > automatically generated) is a solution - it would just be the source of more > confusion for others. > > Your cup of tea would be the edit_polymorphic_path helper, as in this > example I just put up:http://pastie.org/141162 > > - Mislav > > On Jan 20, 2008 1:32 PM, adish <adisha...@gmail.com> wrote: > > > > > Hi, > > > With a simple STI Employee < Person, I can write in the Person > > view.rhtml.erb : > > > ... > > link_to ''Show'', person > > ... > > > and the correct controller will be call depending on the actual > > (concrete) type of the record. > > I think this is because link_to() uses polymorphic_url() internally. > > > However, the restful helpers, such as edit_person_path() fail to > > choose the correct controller and always route to the Person > > controller. This seems inconsistent and confusing. > > > How can I reroute edit_person_path() to take the polymorphic type into > > account, and route to the correct controller? > > > Is this by design or a bug? > > > I hope I made myself clear. > > Thanks, > > Adi--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
2008/1/20 adish <adishavit@gmail.com>:> > Hi Mislav, > > Excellent! Just what I needed. Thanks! > I couldn''t find it in my Rails 2.0.2 installation. > I need the "Simply Helpful" plugin, right?No, that plugin was merged into trunk more than 8 months ago. Those methods aren''t documented because they are added dynamically by metaprogramming magic so RDoc doesn''t pick them up. I will be submitting a documentation patch for polymorphic URL helpers later today because this module was previously undocumented. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav, Can you suggest how to do the exact same thing with formatted URLs? Using adish''s example, something using a helper like edit_formatted_polymorphic_path(record, :xml) This seems logical, but is busted in Edge (see http://dev.rubyonrails.org/ticket/8782). -Chris On Jan 20, 11:53 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> 2008/1/20 adish <adisha...@gmail.com>: > > > > > Hi Mislav, > > > Excellent! Just what I needed. Thanks! > > I couldn''t find it in my Rails 2.0.2 installation. > > I need the "Simply Helpful" plugin, right? > > No, that plugin was merged into trunk more than 8 months ago. Those methods > aren''t documented because they are added dynamically by metaprogramming > magic so RDoc doesn''t pick them up. I will be submitting a documentation > patch for polymorphic URL helpers later today because this module was > previously undocumented.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I've already fixed it, just need to make unit tests and finish the documentation. Then I'll submit it in one big patch. 2008/1/21 Chris Cruft <cch1@hapgoods.com>:> > Mislav, > Can you suggest how to do the exact same thing with formatted URLs? > Using adish's example, something using a helper like > > edit_formatted_polymorphic_path(record, :xml) > > > This seems logical, but is busted in Edge (see > http://dev.rubyonrails.org/ticket/8782). > > -Chris > > On Jan 20, 11:53 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> > wrote: > > 2008/1/20 adish <adisha...@gmail.com>: > > > > > > > > > Hi Mislav, > > > > > Excellent! Just what I needed. Thanks! > > > I couldn't find it in my Rails 2.0.2 installation. > > > I need the "Simply Helpful" plugin, right? > > > > No, that plugin was merged into trunk more than 8 months ago. Those > methods > > aren't documented because they are added dynamically by metaprogramming > > magic so RDoc doesn't pick them up. I will be submitting a documentation > > patch for polymorphic URL helpers later today because this module was > > previously undocumented. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
My hero! On Jan 21, 9:19 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> I''ve already fixed it, just need to make unit tests and finish the > documentation. Then I''ll submit it in one big patch. > > 2008/1/21 Chris Cruft <c...@hapgoods.com>: > > > > > Mislav, > > Can you suggest how to do the exact same thing with formatted URLs? > > Using adish''s example, something using a helper like > > > edit_formatted_polymorphic_path(record, :xml) > > > This seems logical, but is busted in Edge (see > >http://dev.rubyonrails.org/ticket/8782). > > > -Chris > > > On Jan 20, 11:53 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> > > wrote: > > > 2008/1/20 adish <adisha...@gmail.com>: > > > > > Hi Mislav, > > > > > Excellent! Just what I needed. Thanks! > > > > I couldn''t find it in my Rails 2.0.2 installation. > > > > I need the "Simply Helpful" plugin, right? > > > > No, that plugin was merged into trunk more than 8 months ago. Those > > methods > > > aren''t documented because they are added dynamically by metaprogramming > > > magic so RDoc doesn''t pick them up. I will be submitting a documentation > > > patch for polymorphic URL helpers later today because this module was > > > previously undocumented.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---