I have the following code:
wedding = Wedding.where(location_id: user_params[:locationId])
wedding.map(&:guests).each do |member|
user_ids << member.ids
end
In my case :guests
is a active record table, but I have a couple that I would like to pass thru map
to generate the user_ids
So it would be array of methods like this, that I would like to pass: [guests, bride, etc etc]
It would be even better if I could pass the whole array, but otherwise if I can step through the array of methods that would be great too.
Any ideas?
EDIT:
I'm trying this with no luck.. I get: NameError (wrong constant name guests):
roles = ["guests"]
wedding = Wedding.where(location_id: user_params[:locationId])
roles.each do |role|
clazz = Kernel.const_get(role)
wedding.map(&:clazz).each do |member|
user_ids << member.ids
end
end