I have the following model classes...
class Image < ActiveRecord::Base
attr_accessible :description, :title
has_many :imageTags
has_many :tags, :through => :imageTags
end
class Tag < ActiveRecord::Base
attr_accessible :name
has_many :imageTags
has_many :images, :through => :imageTags
end
class ImageTag < ActiveRecord::Base
attr_accessible :position
belongs_to :image
belongs_to :tag
end
And when I use find for getting the Tag with the id 1
t = Tag.find(1);
@images = t.images;
But when I do the same with where, I get a NoMethodError, with the description undefined method 'images':
t = Tag.where(:name => "foo");
@images = t.images;
I also tried adding .includes(:images) before the .where statement, but that doesn't work too. So, how can I get all Images that belong to a Tag?