ruby - What is an ActiveRecord Rails Relation really? -


i trying understand of internals of rails relations, in order use them in queries. therefore, opened console , did tests:

ruby-1.9.2-p180 :036 > skill.where(:second_class => 'wealth ranger').map {|att| att.class}  => [skill(id: integer, name: string, description: string, second_class: string, third_class: string, created_at: datetime, updated_at: datetime)] 

now, not expect output. expect relation or similar. seems traverses every attribute , produces type each one.

what relation in ruby's terms really? totally custom structure? if so, there similarities between hashes , arrays, or should considered totally custom structure?

edit:

after more testing, seems contains objects of class. how operates?

activerecord's relation class in rails 3 layer on top of arel. handles collecting parameters "lazy loading" , rails' simplified query methods (compared straight arel).

the best description i've seen of it's inner workings on ernie miller's blog. wrote meta_search , meta_where knows he's talking about.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -