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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs