Jason Fb wrote in post #1150062: > It took me several years of working with Rails to understand this > nuance, and I believe it is poorly documented in the AR guide. "reading > the source" may be a good idea for some, but remember the Rails source > isn't easy for everyone to read (although a good idea!).
I don't mind so much *reading* the source then relying on the information we get from it. Even if you see that something is implemented in a particular way, you don't know whether it is just incidentally (and in the next minor release will be implemented differently), or whether it is an undocumented feature (which might or might not make it in the API), or whether it is really part of the "official" interface. If something is specified in the API, there is at least good hope that we don't run into incompatibilities (although when looking at the evolution of Rails, this principle seems to have been violated occasionally). > Since it is so important to how AR works, I think this facet of AR > should be documented better in the AR guide (specifically, that the AR > methods return ActiveRelation objects which don't actually fetch > anything until you want to look at them). It's a brilliant > implementation pattern, but counter-intuitive to newbies. It's just "lazy evaluation" at work, and as such not so much "counter-intuitive". It's only that it is not obvious that the design choice was done in this way... Ronald > > -Jason -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0c92246ba34e7b082c0b59e339d67c51%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.

