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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6/28/07, Geoff B <gbuesing@gmail.com> wrote:> > > <%= link_to :name, @company %>Totally awesome! +1 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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/8789Nice, 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 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 -~----------~----~----~----~------~----~------~--~---
link_to already accepts a symbol as the first param and converts it into a string. This change would break the existing api. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6/28/07, Brandon Keepers <bkeepers@gmail.com> wrote:> Nice, but IMHO, this would be more useful: > > class Company < AR::Base > def to_s > name > end > end+1! I''m using the same pattern too. Shouldn''t this be encouraged? It''s a way of saying: you should provide a human-readable representation of your object (yeah, usually just alias name). I do find link_to @company.name, @company very unDRY... and even more when it gets duplicated all over the place... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 28, 6:16 am, Brandon Keepers <bkeep...@gmail.com> wrote:> On Jun 28, 2007, at 7:50 AM, Geoff B wrote: > > 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 %>Yes! Something who''s been thinking alike. http://svn.joshpeek.com/projects/plugins/stringgable_shortcuts/ --~--~---------~--~----~------------~-------~--~----~ 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 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 [@company, @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 <bkeep...@gmail.com> 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 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 -~----------~----~----~----~------~----~------~--~---
Forgot to post the link -- patch is here: http://dev.rubyonrails.org/ticket/8794 On Jun 28, 10:06 am, Geoff B <gbues...@gmail.com> 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 [@company, @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 <bkeep...@gmail.com> 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 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 -~----------~----~----~----~------~----~------~--~---
Which patch are you for? #8789 or #8794 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6/28/07, Geoff B <gbuesing@gmail.com> wrote:> > > It would be nice if ActiveRecord objects had a readable default #to_shttp://pastie.caboo.se/74412 --~--~---------~--~----~------------~-------~--~----~ 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 uploaded a new patch with some minor modification to the existing patch. I gyess it makes more sense to join .to_s values of @company, @perso in case of <%= link_to [@company, @person] %> Thanks, Pratik On 6/28/07, Geoff B <gbuesing@gmail.com> wrote:> > > Forgot to post the link -- patch is here: http://dev.rubyonrails.org/ticket/8794 > > On Jun 28, 10:06 am, Geoff B <gbues...@gmail.com> 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 [@company, @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 <bkeep...@gmail.com> 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 %> > > > > >-- rm -rf / 2>/dev/null - http://null.in Dont judge those who try and fail, judge those who fail to try.. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Everyone jump onto #rails-contrib, ya''ll seem to be online right now. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6/28/07, Josh Peek <joshpeek@gmail.com> wrote:> > > Which patch are you for? #8789 or #8794My vote is for the latter. The former breaks backwards compatibility (like Steven already noticed), and on common models there is rarely more than one attribute ready for link text output. Hacking to_s makes much more sense. (See my pastie) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 28, 10:26 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > It would be nice if ActiveRecord objects had a readable default #to_s > > http://pastie.caboo.se/74412I''ve had that in my plugin, but I like your defaults to name and title better :) http://svn.joshpeek.com/projects/plugins/stringgable_shortcuts/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My2c... You might consider the syntax <%= link_to &:name, @company %> instead of just a symbol, since it fits with existing idioms and wouldn't break backwards compatibility. On 6/28/07, Josh Peek <joshpeek@gmail.com> wrote:> > On Jun 28, 10:26 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> > wrote: > > On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > > > > > It would be nice if ActiveRecord objects had a readable default #to_s > > > > http://pastie.caboo.se/74412 > > I've had that in my plugin, but I like your defaults to name and title > better :) > > http://svn.joshpeek.com/projects/plugins/stringgable_shortcuts/ > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, Mislav! I created a pastie of the to_s-oriented patch, so that others could test out the DRY-ed link_to syntax: http://pastie.caboo.se/74452 With both of these pasties applied, I''ve been refactoring my link_to calls -- ex: <%= link_to @post %> links to the resource, with the @post.title as the link text -- very nice. On Jun 28, 10:26 am, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > It would be nice if ActiveRecord objects had a readable default #to_s > > http://pastie.caboo.se/74412--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Jun 28, 2007 at 11:37:58AM -0400, Obie Fernandez wrote:> You might consider the syntax <%= link_to &:name, @company %> instead > of just a symbol, since it fits with existing idioms and wouldn''t > break backwards compatibility.That isn''t valid Ruby syntax. marcel -- Marcel Molina Jr. <marcel@vernix.org> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6/28/07, Geoff B <gbuesing@gmail.com> wrote:> > Thanks, Mislav! > > I created a pastie of the to_s-oriented patch, so that others could > test out the DRY-ed link_to syntax: http://pastie.caboo.se/74452 > > With both of these pasties applied, I''ve been refactoring my link_to > calls -- ex: <%= link_to @post %> links to the resource, with the > @post.title as the link text -- very nice. >Don''t you all mean <%= link_to h(@company.name), ... %> Where''s the escaping?! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Good catch on the html escaping. I updated the patch so that html escaping happens automatically when the first argument passed in is not a string. So, with <%= link_to @company %> the link text will be automatically escaped. With the standard syntax, you''d need to explicitly escape, as before: < %= link_to h(@company.name), @company %> http://dev.rubyonrails.org/ticket/8794 On Jun 28, 2:48 pm, Courtenay <court3...@gmail.com> wrote:> On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > Thanks, Mislav! > > > I created a pastie of the to_s-oriented patch, so that others could > > test out the DRY-ed link_to syntax:http://pastie.caboo.se/74452 > > > With both of these pasties applied, I''ve been refactoring my link_to > > calls -- ex: <%= link_to @post %> links to the resource, with the > > @post.title as the link text -- very nice. > > Don''t you all mean > > <%= link_to h(@company.name), ... %> > > Where''s the escaping?!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
... or rather, link text is escaped *only if* first argument is an ActiveRecord object, so as not to break any existing behavior. Patch updated, and pastie updated: http://pastie.caboo.se/74543 On Jun 28, 3:29 pm, Geoff B <gbues...@gmail.com> wrote:> Good catch on the html escaping. > > I updated the patch so that html escaping happens automatically when > the first argument passed in is not a string. > > So, with <%= link_to @company %> the link text will be automatically > escaped. > > With the standard syntax, you''d need to explicitly escape, as before: < > %= link_to h(@company.name), @company %> > > http://dev.rubyonrails.org/ticket/8794 > > On Jun 28, 2:48 pm, Courtenay <court3...@gmail.com> wrote: > > > On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > Thanks, Mislav! > > > > I created a pastie of the to_s-oriented patch, so that others could > > > test out the DRY-ed link_to syntax:http://pastie.caboo.se/74452 > > > > With both of these pasties applied, I''ve been refactoring my link_to > > > calls -- ex: <%= link_to @post %> links to the resource, with the > > > @post.title as the link text -- very nice. > > > Don''t you all mean > > > <%= link_to h(@company.name), ... %> > > > Where''s the escaping?!--~--~---------~--~----~------------~-------~--~----~ 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, I''ve converted this functionality into a quick plugin and also added some method_missing magic to enable form like link_to_nice_name(@person) ( which uses @person.nice_name ). Grab it from http://linktomagic.googlecode.com/svn/link_to_magic/ Thanks, Pratik On 6/28/07, Geoff B <gbuesing@gmail.com> wrote:> > ... or rather, link text is escaped *only if* first argument is an > ActiveRecord object, so as not to break any existing behavior. > > Patch updated, and pastie updated: http://pastie.caboo.se/74543 > > On Jun 28, 3:29 pm, Geoff B <gbues...@gmail.com> wrote: > > Good catch on the html escaping. > > > > I updated the patch so that html escaping happens automatically when > > the first argument passed in is not a string. > > > > So, with <%= link_to @company %> the link text will be automatically > > escaped. > > > > With the standard syntax, you''d need to explicitly escape, as before: < > > %= link_to h(@company.name), @company %> > > > > http://dev.rubyonrails.org/ticket/8794 > > > > On Jun 28, 2:48 pm, Courtenay <court3...@gmail.com> wrote: > > > > > On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > > Thanks, Mislav! > > > > > > I created a pastie of the to_s-oriented patch, so that others could > > > > test out the DRY-ed link_to syntax:http://pastie.caboo.se/74452 > > > > > > With both of these pasties applied, I''ve been refactoring my link_to > > > > calls -- ex: <%= link_to @post %> links to the resource, with the > > > > @post.title as the link text -- very nice. > > > > > Don''t you all mean > > > > > <%= link_to h(@company.name), ... %> > > > > > Where''s the escaping?! > > > > >-- http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ack! more method missing! this means more functions people can''t look up in the API. Why not name it something else that is searchable, and use a symbol or something link_to_method(:nice_name, @person) On 7/1/07, Pratik <pratiknaik@gmail.com> wrote:> > Hi, > > I''ve converted this functionality into a quick plugin and also added > some method_missing magic to enable form like > link_to_nice_name(@person) ( which uses @person.nice_name ). > > Grab it from http://linktomagic.googlecode.com/svn/link_to_magic/ > > Thanks, > Pratik > > On 6/28/07, Geoff B <gbuesing@gmail.com> wrote: > > > > ... or rather, link text is escaped *only if* first argument is an > > ActiveRecord object, so as not to break any existing behavior. > > > > Patch updated, and pastie updated: http://pastie.caboo.se/74543 > > > > On Jun 28, 3:29 pm, Geoff B <gbues...@gmail.com> wrote: > > > Good catch on the html escaping. > > > > > > I updated the patch so that html escaping happens automatically when > > > the first argument passed in is not a string. > > > > > > So, with <%= link_to @company %> the link text will be automatically > > > escaped. > > > > > > With the standard syntax, you''d need to explicitly escape, as before: < > > > %= link_to h(@company.name), @company %> > > > > > > http://dev.rubyonrails.org/ticket/8794 > > > > > > On Jun 28, 2:48 pm, Courtenay <court3...@gmail.com> wrote: > > > > > > > On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > > > > Thanks, Mislav! > > > > > > > > I created a pastie of the to_s-oriented patch, so that others could > > > > > test out the DRY-ed link_to syntax:http://pastie.caboo.se/74452 > > > > > > > > With both of these pasties applied, I''ve been refactoring my link_to > > > > > calls -- ex: <%= link_to @post %> links to the resource, with the > > > > > @post.title as the link text -- very nice. > > > > > > > Don''t you all mean > > > > > > > <%= link_to h(@company.name), ... %> > > > > > > > Where''s the escaping?! > > > > > > > > > > > > -- > http://m.onkey.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
$ find . | grep \.rb$ | xargs grep -s ''method_missing'' | wc -l 59 :-P On 7/2/07, Courtenay <court3nay@gmail.com> wrote:> > ack! more method missing! this means more functions people can''t look > up in the API. > > Why not name it something else that is searchable, and use a symbol or something > > link_to_method(:nice_name, @person) > > > On 7/1/07, Pratik <pratiknaik@gmail.com> wrote: > > > > Hi, > > > > I''ve converted this functionality into a quick plugin and also added > > some method_missing magic to enable form like > > link_to_nice_name(@person) ( which uses @person.nice_name ). > > > > Grab it from http://linktomagic.googlecode.com/svn/link_to_magic/ > > > > Thanks, > > Pratik > > > > On 6/28/07, Geoff B <gbuesing@gmail.com> wrote: > > > > > > ... or rather, link text is escaped *only if* first argument is an > > > ActiveRecord object, so as not to break any existing behavior. > > > > > > Patch updated, and pastie updated: http://pastie.caboo.se/74543 > > > > > > On Jun 28, 3:29 pm, Geoff B <gbues...@gmail.com> wrote: > > > > Good catch on the html escaping. > > > > > > > > I updated the patch so that html escaping happens automatically when > > > > the first argument passed in is not a string. > > > > > > > > So, with <%= link_to @company %> the link text will be automatically > > > > escaped. > > > > > > > > With the standard syntax, you''d need to explicitly escape, as before: < > > > > %= link_to h(@company.name), @company %> > > > > > > > > http://dev.rubyonrails.org/ticket/8794 > > > > > > > > On Jun 28, 2:48 pm, Courtenay <court3...@gmail.com> wrote: > > > > > > > > > On 6/28/07, Geoff B <gbues...@gmail.com> wrote: > > > > > > > > > > Thanks, Mislav! > > > > > > > > > > I created a pastie of the to_s-oriented patch, so that others could > > > > > > test out the DRY-ed link_to syntax:http://pastie.caboo.se/74452 > > > > > > > > > > With both of these pasties applied, I''ve been refactoring my link_to > > > > > > calls -- ex: <%= link_to @post %> links to the resource, with the > > > > > > @post.title as the link text -- very nice. > > > > > > > > > Don''t you all mean > > > > > > > > > <%= link_to h(@company.name), ... %> > > > > > > > > > Where''s the escaping?! > > > > > > > > > > > > > > > > > > > -- > > http://m.onkey.org > > > > > > > > > > >-- http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> ack! more method missing! this means more functions people can''t look > up in the API.Agree. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---