Hi.
Any way to write this more efficiently? Can I make the active record handle this through some kind of association?
@images = current_user.foo_models.each do |foo| @images.concat(foo.images) end
Any help appreciated.
Hi.
Any way to write this more efficiently? Can I make the active record handle this through some kind of association?
@images = current_user.foo_models.each do |foo| @images.concat(foo.images) end
Any help appreciated.
class FooModel < ActiveRecord::Base
belongs_to :user
has_many :images
end
class User < ActiveRecord::Base
has_many :foo_models
has_many :images, :through => :foo_models
end
current_user.images