Selecting specific rows from table based on a foreign key in paginate statement.

0 views
Skip to first unread message

Carson

unread,
Feb 15, 2008, 9:47:56 PM2/15/08
to MidWest.rb
I have a table named "products" accessed by a foreign key "country" in
in the "countries" table.

From a view named "browse_by_country.rhtml", I want to link_to an
action called "list_products_by_country" providing a foreign key
provided from the "countries" table named "xref":

-- snipit from view --

<% for country in @countries %>
<%= link_to country.name, { :action =>
"list_products_within_country",
:xref => @country } %>
<br>
<% end %>

-- end smipit --

Then, in the controller action, I want to create a list of "products"
possesing the foreign key "country" = xref (in the pagination
statement. Here's my attemtp:

-- snipit from controller --

def list_products_within_country
@product_pages, @products = paginate :products,
:per_page => 10,
:conditions => [" 'country'
= ?", params[:xref]]

render :action => 'list'
end

-- end smipit --

It doesn't work and I'm on the bleeding edge of my knowledge.

Can someone help me?
Reply all
Reply to author
Forward
0 new messages