Forum: Ruby on Rails Brand newbie question relating to link_to

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
David S. (Guest)
on 2006-03-28 05:51
(Received via mailing list)
I recently dived into Rails and am having trouble with the link_to
I'd like to pass some parameters to the action being called and am not
how to do it.   Essentially, I want to hyperlink a total count of bugs
queried from the database to a method that will return the bug numbers
clicked on.  I have a method, bug_total, that returns the total number
display in the view.  I have another method, total_bugs, that will
the bugzilla url with all the bugid's for that particular build when

Below is what I have in my view.  I'd like to pass the
some parameters(build_number, developer_name, product_name) based on the
current build.  I've tried many ways and haven't been successfull, yet.
help is greatly appreciated.  Thanks!

   for build in @bugDashboard
<span class="tabledata">
          <%= link_to build.bug_total, {:controller => "dashboard",
                                        :action => "total_bugs"} %>

Jon (Guest)
on 2006-03-28 06:02
> <%
>    for build in @bugDashboard
>  %>
> <span class="tabledata">
>           <%= link_to build.bug_total, {:controller => "dashboard",
>                                         :action => "total_bugs"} %>
> </span>
> .....

<%= link_to (build.bug_total), :controller ....... %>

that should work...
François B. (Guest)
on 2006-03-29 01:56
(Received via mailing list)
2006/3/27, David S. <removed_email_address@domain.invalid>:
> <%
>    for build in @bugDashboard
>  %>
> <span class="tabledata">
>           <%= link_to build.bug_total, {:controller => "dashboard",
>                                         :action =>
> "total_bugs"} %>
> </span>

Hmm, have you tried this ?

build_number, developer_name, product_name
<%= link_to build.bug_total, :controller => "dashboard", :action =>
"total_bugs", :build_number => '123', :developer_name => 'francois',
:product_name => 'rails' %>

#link_to automatically makes any leftover parameters query parameters:


In the action, you can access the parameters using the params Hash:

def total_bugs
  params[:product_name] # => "rails"
  params[:build_number] # => "123"
  params[:developer_name] # => "francois"

NOTE:  All parameters are strings in the params Hash.

When you are ready to explore routes, you can build a URL like this


  :controller => "dashboard", :action => "total_bugs"

which would give you the exact same params Hash as above.

Hope that helps !
dsliwa (Guest)
on 2006-03-29 04:16
(Received via mailing list)
Thank you Francois!  That worked great.  I haven't tried the route way,
but will when I get this thing up and running.  You help is greatly
This topic is locked and can not be replied to.