PDA

View Full Version : link_to and redirect_to params


bradeck
November 28th, 2005, 04:46 PM
My question is specific to identifying how to use a typical html 'target' but it may come down to somply asking how to pass typical html attributes within a link_to or redirect_to for a standard link on a site.

Given my newness to all this there may also be a better framework solution for approaching things like this.

(I also tried messing with the map hash via routes.rb.

rob
November 28th, 2005, 06:44 PM
Brad,

The target tag works like this with link_to:


<%= link_to 'Your Link Desc', { :controller => 'ctrlname', :action => 'actnname' }, { :target => '_blank' } %>

bluetechnx
November 28th, 2005, 10:47 PM
Brad,

The target tag works like this with link_to:


<%= link_to 'Your Link Desc', { :controller => 'ctrlname', :action => 'actnname' }, { :target => '_blank' } %>



Also, I believe if you are linking to a specific action in the current controller you can leave off the controller argument in the tag.

rob
November 28th, 2005, 10:48 PM
Yes, you can. I often use simply:


<%= link_to 'Home', :action => 'index' %>


Makes for much simpler code :)