I have a controller and two models, a user and a store.
A user has_many stores. Inside stores I have a method get_items which lists items.
get_items itself needs a reference to the user.
What I have done now is the following
@items = user.stores.first.get_items(user)
this looks weird to me since the initial caller has to pass itself as an argument to the get_items method.
What would you recommend?
best,
phil
If you’ve defined the relation in two directions,
then you have access to the
userthat a store belongs to within theStoreinstance. So you should be able to writeand it should use the correct user. The call to get_items could then be
I would personally rename
get_itemstoitems.