Reputation: 1121
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..
Upvotes: 0
Views: 300
Reputation: 15492
@colors = Color.find(:all, :conditions => ["user_id != ?", current_user.id])
Assuming user_id is the foriegn_key field.
Upvotes: 1