Model associations and optimization problem

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.

On Mon, Mar 1, 2010 at 11:09 AM, Michal B. [email protected]
wrote:

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