Ruby on Rails
Wednesday, February 2, 2011
I want is to set
default_scope :order => 'created_at ASC'
for all models on default. How is that done?
-- On Wed, Feb 2, 2011 at 6:23 AM, Walter Lee Davis <waltd@wdstudio.com> wrote:
Well, I imagine you could, as long as all of your models had a key in common. I mean, there's no practical difference between vanilla Rails and this:
default_scope order('id ASC')
But if all of your models had a :position maybe you could do this
default_scope order('position ASC')
and see what happens. I have my doubts -- everything Controller-wise inherits from ApplicationController, and what about controllers that don't just manage one model? This sort of thing has got to end badly is my guess.
Walter
On Feb 1, 2011, at 10:15 PM, slava wrote:
I know I can set default_scope for individual active record model, but
can I set one up for the whole application?
thanks
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment