The use case where you wouldn't know the first part of the url would
be:

<%= link_to 'New Person', new_polymorphic_url [EMAIL PROTECTED], @person] %>

...where @parent could be an instance of Company, and instance of
Category, or nil. @parent would be set in the controller, based upon
whether :company_id or :category_id were in the params (this technique
is detailed in this post: 
http://revolutiononrails.blogspot.com/2007/05/drying-up-polymorphic-controllers.html
)

Depending upon the value of @parent, the outputted href would be one
of the following:

/people/new
/categories/5/people/new
/companies/12/people/new

So instead of doing conditional logic to decide whether to call
new_person_url, category_new_person_url(@category), or
company_new_person_url(@company), I'm just calling
new_polymorphic_url, and leveraging the logic built in to that.





On Jun 22, 7:46 pm, "Michael Koziarski" <[EMAIL PROTECTED]> wrote:
> > <%= link_to 'New Person', new_polymorphic_url [EMAIL PROTECTED], @person] %>
>
> But here you know you have a company already.  I don't really see the
> utility of extending those cases unless there are common use cases
> where you *don't* know what the first part of the url is.
>
> --
> Cheers
>
> Koz


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to