I need to convert a rails 2.3 site so that all external URLs open in a new window. I could go though every call to link_to
and add :target => \'_blank\'>
You just add an helper to add this options in your link_to
If you want add it on each link_to to can add on ApplicationHelper
def link_to(*args, &block)
if block_given?
args = [(args.first || {}), (args.second || {}).merge(:target => '_blank')]
else
args = [(args.first || {}), (args.second || {}), (args.third || {}).merge(:target => '_blank')]
end
super(args, block)
end
Or you can create your own link_to helper
def link_to_blank(*args, &block)
if block_given?
args = [(args.first || {}), (args.second || {}).merge(:target => '_blank')]
else
args = [(args.first || {}), (args.second || {}), (args.third || {}).merge(:target => '_blank')]
end
link_to(args, block)
end