I find myself requiring this. Assuming cart is a model which has a list of users.
def index_of_item
cart.users.each_with_index do |u, i|
if u == current_user
return i
end
end
What's an easier way to get the index of an association like this?