You can always use

link_to @person { "Click me" }

if you find that infinitely more readable than

link_to "Click me", @person

without the need to introduce a backwards incompatible change that would
break every Rails app ever written.


On Fri, Mar 15, 2013 at 3:39 PM, Michael Grohn <grohn.mich...@gmail.com>wrote:

> @Matt jones
>
> > I'd guess that it's because while the body is typically simple (a string
> or variable), the second argument can also be a bunch of params for
> url_for:
> >
> > link_to 'thingy', :controller => 'wat', :action => 'huh', :protocol =>
> 'wtf'
>
> There are 4 signatures for the link_to helper method:
>
>     link_to(body, url, html_options = {})
>     link_to(body, url_options = {}, html_options = {})
>     link_to(options = {}, html_options = {})
>     link_to(url, html_options = {})
>
> Your example would fit the second signature, which has no url argument,
> but a url_options hash instead. This is fine, options always go at the end
> of a method call.
>
> The first signature is the one that bothers me.
>
>
>
> @Zamith
>
> > link_to url: @person, body: "Click me"
>
> I thought of that one too, but it's almost just as ugly as
>
>     link_to "Click me", @person
>
>
>
> Another reason why it bothers me, is that the body can also be given as a
> block, in which case, tho body goes at the very end of the method call and
> the url at the beginning. So in case of a block-given body, the order is
> just reversed:
>
>     link_to @person do "Click me" end
>
> Not very consistent, he?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to