3 ms·
Main reason they used those find_by / find_all_by methods is that there's no good way to shortly express one-field finder. Compare DM: Article.first(:auth
by xentronium 16y ago
Main reason they used those find_by / find_all_by methods is that there's no good way to shortly express one-field finder.
Compare
DM: Article.first(:author => person)
AR: Article.first(:conditions => {:author_id => person.id})
AR shortcut: Article.find_by_author_id(person.id)
AREL: Article.where(:author => person).first # not sure about that
- didip 16y agoThis is one thing that surprise me about Rails 3: AREL: Article.where(:author => person).first Why the sudden departure? Arel looks familiar to SqlAlchemy, Hibernate Query Language, and Sequel. And far from everything is an object in ActiveRecord. And why reinvent the wheel? http://sequel.rubyforge.org/ http://sequel.rubyforge.org/ have exists for a while now.
- xentronium 16y agoIt's been a long debate, and yes, it's almost like sequel. Actually, ARel positions itself into the same niche as sequel, i.e. low-level toolkit to build frameworks on. In my opinion, sequel is an absolute kick-ass sort of thing, it's just that ultra-cool if you have time and will to hack. Further reading: http://sequel.heroku.com/2010/02/06/arel-sequel-differences-part-1/ http://sequel.heroku.com/2010/02/06/arel-sequel-differences-... http://sequel.heroku.com/2010/02/10/arel-sequel-differences-part-2/ http://sequel.heroku.com/2010/02/10/arel-sequel-differences-... http://sequel.heroku.com/2010/02/23/the-benefits-without-the-costs/ http://sequel.heroku.com/2010/02/23/the-benefits-without-the... http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/ http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-... -- note comments bout sequel