I've got a model, Agency, which has_many :users
. Users can have roles- :agent, :admin, so I created methods to pull that subset of @agency.users
Agency.rb
def agents
users.with_roles(:agent, self)
end
What I want is, effectively, f.association :agents, collection: User.all
to allow agencies to hire anybody. Trying this gives, unsurprisingly, "Association :agents not found". Changing it to f.association @agency.agents, collection: User.all
also fails with "Association #<ActiveRecord::AssociationRelation .....not found"
From this question, it seems like simpleform can't handle the AssociationRelation, but only an Association.
Can I alter my method to return just an association? Can I alter my simpleform to handle the AssociationRelation?