Forum: Ruby on Rails link_to question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Scott Phelps (Guest)
on 2005-12-17 18:42
(Received via mailing list)
Man, I was up until 5am coding

Hey, does anyone know how to pass extra paramaters in a link_to - I
can't seem to get the syntax right:

This does NOT work:

<div id="header">
     <ul id="primary">
         <li>
         <%= link_to 'General',{:action => "new_project",:id =>
@project},{:class => "current"},{:foo => "bar"}%>
     </ul>
</div>

But It shows what I am trying to do

It seem it should according to RoR API
http://api.rubyonrails.com/classes /ActionView/Helpers/UrlHelper.html
#M000332
Jakob L. Skjerning (Guest)
on 2005-12-17 18:57
(Received via mailing list)
On Dec 17, 2005, at 17:41, Scott Phelps wrote:
> Hey, does anyone know how to pass extra paramaters in a link_to - I
> can't seem to get the syntax right:
>
> This does NOT work:
>         <%= link_to 'General',{:action => "new_project",:id =>
> @project},{:class => "current"},{:foo => "bar"}%>

This does:

link_to 'General', {:action => "new_project", :id => @project, :foo
=> "bar"}, {:class => "current"}

The hash given in the second parameter for link_to, options, is used
to build the URL to link to.


--
Jakob S. - http://mentalized.net
Scott Phelps (Guest)
on 2005-12-17 19:15
(Received via mailing list)
On Dec 17, 2005, at 11:55 AM, Jakob L. Skjerning wrote:

>
> link_to 'General', {:action => "new_project", :id => @project, :foo
> => "bar"}, {:class => "current"}
>
> The hash given in the second parameter for link_to, options, is
> used to build the URL to link to.

Cool, thanks!
This topic is locked and can not be replied to.