I have the following structure
class List < ActiveRecord::Base
has_many :global_lists
end
class GlobalList < ActiveRecord::Base
set_table_name :globals_lists
belongs_to :list
end
and the following:
gl=GlobalList.find(1) #works
gl.list #works
gm=GlobalList.where(:global_id => 23).includes(:list) #works
gm.list # doesn't work
How do I access the list when using a where for returning the object?
thx
edit: is there a way for me to flatten this and get all the lists that have this? I guess I could iterate through but have the feeling there might be some syntax that I’m not aware of
This line:
returns a collection of models. You need to first the first to get the list.