Forgot to post the link -- patch is here: http://dev.rubyonrails.org/ticket/8794

On Jun 28, 10:06 am, Geoff B <[EMAIL PROTECTED]> wrote:
> I like the leveraging of the #to_s. The syntax of <%= link_to
> @company, @company %> isn't as DRY as it could be, so I put in a patch
> that allows you to do this:
>
> <%= link_to @person %>
> <%= link_to [EMAIL PROTECTED], @person] %>
>
> The link text is the #to_s of the object, or if an Array is passed,
> the #to_s of the last object in the array.
>
> It would be nice if ActiveRecord objects had a readable default #to_s
> -- even if it were something like "Person 12". Or, if the object
> responded to :title or :name, one of those could be used.
>
> On Jun 28, 6:16 am, Brandon Keepers <[EMAIL PROTECTED]> wrote:
>
> > On Jun 28, 2007, at 7:50 AM, Geoff B wrote:
>
> > > Hi, I just put in a patch that allows you to DRY up this:
>
> > > <%= link_to @company.name, @company %>
>
> > > to this:
>
> > > <%= link_to :name, @company %>
>
> > > The symbol indicates the method to be called on the object passed in
> > > the link_to options.
>
> > >http://dev.rubyonrails.org/ticket/8789
>
> > Nice, but IMHO, this would be more useful:
>
> > class Company < AR::Base
> >    def to_s
> >      name
> >    end
> > end
>
> > <%= link_to @company %>
>
> > That's the pattern I've been using, but my link_to's look like this:
>
> > <%= link_to @company, @company %>


--~--~---------~--~----~------------~-------~--~----~
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