Specifying a :target when using link_to with Rails 3.1

This seems contrary to some of the docs I’ve read, so I’ll mention it here in case anyone else has this trouble.

When specifying a :target => “_blank” as part of a link_to, I had to put the destination url parameters inside a hash:

= link_to "Preview", { :action => :preview, :id => flyer}, :target => "_blank"

= link_to "Preview", :action => :preview, :id => flyer, :target => "_blank"

Otherwise the target=_blank is treated as a text query string instead of as a target directive.

Leave a Reply

Your email address will not be published. Required fields are marked *