I think it should add the sort by I'd by default and either have a setting to turn it off or detect if there is a default scope and not add it if a default scope exists.
I am an vacation so I can't fix or look more deeply into this until I get back. Sent from my Verizon Wireless BlackBerry -----Original Message----- From: "G. Sobrinho" <[email protected]> Date: Thu, 25 Jun 2009 03:06:59 To: <[email protected]> Subject: Re: Order of records with default_scope / Sorry, i sended without the second part... So, the database sort by id none is specified. The ActiveScaffold doesnt need to add the order clause. If I explicit a sort column (clicking on header of column or setting in controller), the AS needs to add the clause. Othewise, no. I think this is the best form. 2009/6/25 G. Sobrinho <[email protected]> > But the databases, by default, sort by id if nothing is specified. So, the > ActiveScaffold dont need to set it which avoid the defaut_scope in my > situation. > > > 2009/6/24 <[email protected]> > >> Yes sort of? >> >> See active scaffold adds sort by id by default unless you tell it to do >> differently. >> You told your model to have some default scopes as well. The order in >> which these are added must be active scaffold scope first, default_scope >> second, because the id scope shows up higher in priority. >> >> I believe you can turn off the sorting by id, >> >> config.columns[:id].sort = false >> >> or something like that, it might be config.list.columns[:id].sort = false >> >> ~kenny >> >> Sent from my Verizon Wireless BlackBerry >> >> ------------------------------ >> *From*: "G. Sobrinho" >> *Date*: Wed, 24 Jun 2009 23:39:37 -0300 >> *To*: <[email protected]> >> *Subject*: Re: Order of records with default_scope >> Yes, the id ASC are added because ActiveScaffold tryed to sort by it. >> >> But by default, in theory, the Active Scaffold can't sort the records by >> any fields except I explicited it. Not? >> >> 2009/6/24 <[email protected]> >> >>> I belive active scaffold tries to order by I'd by default so it is adding >>> it. >>> >>> I would use the config sort that active scaffold provides for you, look >>> at the list config wiki page for examples >>> >>> Sent from my Verizon Wireless BlackBerry >>> >>> ------------------------------ >>> *From*: "G. Sobrinho" >>> *Date*: Wed, 24 Jun 2009 19:07:39 -0300 >>> *To*: activescaffold<[email protected]> >>> *Subject*: Order of records with default_scope >>> Hello, >>> >>> I'm using default_scope on some models to sort the records but the AS >>> have a issue with that. >>> >>> For example, i have a model named Page: >>> >>> class Page < ActiveRecord::Base >>> default_scope :joins => :category, :order => 'categories.order ASC, >>> pages.order ASC' >>> end >>> >>> >>> When I access the list, the SQL generated is (order part): "ORDER BY >>> pages.id ASC, categories.order ASC, pages.order ASC" >>> But I don't setted the AS to sort by id. Well, this doesn't work. >>> >>> It's a bug? >>> >>> >>> Thank you >>> >>> -- >>> Regards, >>> >>> Gabriel Sobrinho >>> E-mail: [email protected] >>> Phone: +55 31 8775 8378 >>> >>> Don't print this e-mail. The nature is thankful and your money also. >>> >>> >>> >>> >>> >> >> >> -- >> Regards, >> >> Gabriel Sobrinho >> E-mail: [email protected] >> Phone: +55 31 8775 8378 >> >> Don't print this e-mail. The nature is thankful and your money also. >> >> >> >> >> >> > > > -- > Regards, > > Gabriel Sobrinho > E-mail: [email protected] > Phone: +55 31 8775 8378 > > Don't print this e-mail. The nature is thankful and your money also. > -- Regards, Gabriel Sobrinho E-mail: [email protected] Phone: +55 31 8775 8378 Don't print this e-mail. The nature is thankful and your money also. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
