Rails - check if record exists in has_many association
<p>I'm not sure if my question is worded correctly.</p>

<p>I have three models: <code>User</code>, <code>Item</code>, and <code>UserItem</code>.</p>

<pre><code>user has_many :user_items
user has_many :items, through :user_items

item has_many :user_items
item has_many :users -&gt; {uniq}, through :user_items
item belongs_to :user

user_item belongs_to :user
user_item belongs_to :item
</code></pre>

<p>I need a way to see if a user has an item to make <code>if</code> statements in my item views  But here's the catch, user_items have <code>enum status: [ :pending, approved]</code>.  So I need to see if a <code>current_user</code> has a certain <code>:pending</code> item.</p>

<p>For example when a user visits item1's view page I have the item_controller's show action declare <code>@item = Item.find_by_id(params[:id])</code>.  But then what can I do with this <code>@item</code> to see if a user has this item?</p>