Parked at Loopia - i’d like to get all of the graphics of
a certain category (not theme) by specifying the category id, but
none of the graphics are associated with a category_id, just a
theme_id. I included a solution I wrote that works fine, but it looks
incredibly ugly and there has to be a “cleaner” way. Any ideas?
Parked at Loopia - i’d like to get all of the graphics of
a certain category (not theme) by specifying the category id, but
none of the graphics are associated with a category_id, just a
theme_id. I included a solution I wrote that works fine, but it looks
incredibly ugly and there has to be a “cleaner” way. Any ideas?
Graphic.find(:all, :include => [:themes => :categories],
:conditions => [“categories.id = ?”, params[:id]])
Or something close to that.
you could alternatively define your category model as such
class Category < ActiveRecord::Base
has_many :themes
has_many :graphics, :through => :themes
end
then;
@category = Category.find(id, :include => :graphics)
@graphics = @category.graphics.
Philip H. wrote:
Parked at Loopia - i’d like to get all of the graphics of
a certain category (not theme) by specifying the category id, but
none of the graphics are associated with a category_id, just a
theme_id. I included a solution I wrote that works fine, but it looks
incredibly ugly and there has to be a “cleaner” way. Any ideas?Graphic.find(:all, :include => [:themes => :categories],
:conditions => [“categories.id = ?”, params[:id]])Or something close to that.