« A subtle potential bug in most Rails applications | Main | Charity Ruby Workshop at the Scottish Ruby Confererence »

March 26, 2012

Comments

Nzkoz

Generally speaking, my advice is never ever ever use default_scope. No, not even then.

Sbfaulkner

A default_scope for ignoring logically deleted records is the only use case I've found that hasn't bit me in the a** at some point

A_matsuda

Agree that default_scope + order smells.
BTW we have AR::Relation#reorder method for this case
https://github.com/rails/rails/blob/ded74df/activerecord/lib/active_record/relation/query_methods.rb#L120

Wish.reorder("created_at desc").limit(3)

Coffeeaddict

I wish SQL would just die

The comments to this entry are closed.

Now in Beta

  • Programming Ruby, 3rd Edition
    Third Edition, Covering Ruby 1.9, now available
My Photo

Pragmatic Stuff

Photos

  • www.flickr.com
    This is a Flickr badge showing public photos from pragdave tagged with pragdave_badge. Make your own badge here.