views:

18

answers:

1

hi..

their is a table called Colors

@user = User.find(currentuser.id)

@user.colors, displays all the colors of current_user

but,

I want to fetch the colors of all other users apart from current user's

please, tell me what will be code like

I tried like, @c = Color.find(:all), this displays all the records

Is there any condition to avoid current user records..

+1  A: 

@colors = Color.find(:all, :conditions => ["user_id != ?", current_user.id])

Assuming user_id is the foriegn_key field.

Rishav Rastogi
thanks, for the solution
nirmal
what is the relationship between Users and Colors? This will only work if a Color :belongs_to a User. It seems more likely to me that you want a :has_many_through relationship.
marshally