I’m having trouble discovering the correct syntax for passing an array
of data-record-ids to a find (or paginate – same thing, right?
:condition clause in order to create an array of all the records with
the IDs in the passed-in array.
In my .rhtml, I have:
<%= link_to @pa_bugs.length.to_s, { :action => ‘list_by_ids’,
:bug_id_list => @bug_nums }, :title => @bug_nums.join(", ") %>
This works good, gives me a link like 3, calls my list_by_ids method,
and even has a cool URL-title (mouseover tool-tip) with a list of the
bugs, vis: “2017, 2023, 2104”. So far, so good.
In my controller.rb, I have
def list_by_ids
@bug_pages, @bugs = paginate :bugs,
:conditions => ['WHERE bug_id IN ?', :bug_id_list],
:per_page => 25,
:order_by => 'priority, bug_severity, bug_id'
render :action => 'list'
end
It seems that, in the conditions line, my use of bug_id_list isn’t doing
what I think it should. I’ve tried a few variations (like
:param[“bug_id_list”], etc.) but, clearly, I don’t understand the
correct syntax here.
Can I get a hint?
For extra-credit, can you explain the concepts behind how data is passed
from .rhtml to controller.rb, so I an figure out the similar problem,
next time?
Thanks!