[Rails] Re: how to set default_scope for the whole application?
> > I want is to set > > default_scope :order => 'created_at ASC' > > for all models on default. How is that done? If you want to do this no matter what I think there should be a way to do it at initialization. If you are using Rails 2.3.x you might be able to do it in 'new_rails_defaults.rb' in folder config/ initizializers. I have not used Rails 3 yet so I don't know where I would make the change in that version, there is a comment in 'new_rails_defaults.rb' saying that the contents of that script will be default in Rails 3 and the script can be removed when Rails is upgraded to 3 so maybe the script will not run, but you can always try anyway. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how to set default_scope for the whole application?
On Feb 2, 2:00 pm, Slava Mikerin wrote: > I want is to set > default_scope :order => 'created_at ASC' > for all models on default. How is that done? I might be wrong but unless you don't have IDs in your tables what you are trying to do is equivalent to leaving things as they are since the IDs are created in ascending order and retrieve in the same way (maybe I read somewhere that Postgre might be an exception), the same thing that happens with the values of created_at. That is, unless you are planning on changing the value of created_at manually after the record has already been created or the computer clock is reset or... pick your choice of "strange" stuff here. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.