Hi guys,

ActiveRecord in rails3 has a nice improvement where most of the API
returns a ActiveRecord::Relation so you can chain things together.

> Asset.where(:project_id => 1).class => ActiveRecord::Relation

One exception at the moment when using an association, it returns an
Array:

class Project
  has_many :assets
end

> Project.first.assets.class => Array

The problem with this is we lose chain-ability, which means I can't do
things like this:

> @project = Project.first
> @project.assets.where(:active => true)

though I can get the same thing with something like this

> Asset.where(:project_id => 1, :active => true)

Personally I prefer lazy loading and chaining and was wondering if
it's possible with associations, or am I missing something, any
thoughts?

Daniel

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to