Forum: Ruby on Rails Filtering items within scaffold

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.
26ca684555abbdb44f01bd1e165e649b?d=identicon&s=25 Vince W. (vince)
on 2006-04-19 22:07
I'm messing with the agiles store example.  I added a field in my
product table (user_id) that is also a foreign key relationship via
fk_products_user

In my scaffold I'd like to list the products as usual, but only those
products from the logged in user.  I assume that would be done in the
controller..

How would I extend the basic controller:

  def list
    @product_pages, @products = paginate :products, :per_page => 10
  end

to Also account for the logged in user?

Thanks..
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-04-19 23:04
(Received via mailing list)
You can pretty much feed it any of the standard find options, so
:conditions=>["user_id = ?", user] might work.

On Wednesday, April 19, 2006, at 10:07 PM, Vince W. wrote:
>  def list
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails


_Kevin
26ca684555abbdb44f01bd1e165e649b?d=identicon&s=25 Vince W. (vince)
on 2006-04-19 23:23
Kevin Olbrich wrote:
> You can pretty much feed it any of the standard find options, so
> :conditions=>["user_id = ?", user] might work.
>

That worked! Thanks!
This topic is locked and can not be replied to.