I am running RAILS 3.0.9, and for the life of me, I can not get RAILS to do the new lazy loading.
My gemfile is:
gem 'rails', '3.0.9'
gem 'sqlite3'开发者_JS百科
gem 'nifty-generators', '>= 0.4.6'
gem 'mocha', :group => :test
gem 'carrierwave'
gem 'rmagick'
gem 'devise', '1.1.rc0'
gem 'jquery-rails', '>= 1.0.3'
And if I do:
Period.where("id=1")
I get:
[#<Period id: 1, start: "2011-07-06", end: "2011-07-13", created_at: "2011-07-06 23:01:46", updated_at: "2011-07-06 23:01:46"]
I really need it to do the ActiveRecord::Relation thing instead! Anyone know what's going on?
You are doing the ActiveRecord::Relation
thing.
foo = Period.where("id=1") # does AR::Relation thing
foo.select( :start ) # does AR::Relation thing
p foo.to_a # Does SQL cmd thing cuz u forced AR::Relation thing to SQL
You should only see your start column reported.
An ActiveRecord::Relation
doesn't evaluate until forced to... like you want it to print values.
精彩评论