Reputation: 646
I have User and Technology table. My association is User has_many technologies and not belongs_to user
. I need to check whether the user contains particular technology or not
Example:
@technology = Technology.find_by_url "some_url"
@user = User.find params[:id]
Now i need to check whether the user has particular technology.
Upvotes: 2
Views: 358
Reputation: 417
exists? can do this for you.
@user.technologies.exists?(@technology.id)
Upvotes: 4