On Wed, 18 Feb 2015 15:57:16 +0100 Sergio Cambra <[email protected]> wrote:
> In my experience, I think the same, :order in default_scope usually gives > unexpected issues. > > In AS you usually define order in list config and leave user override it > clicking on headings, but calculation subquery is not using that part, so it > works for a normal use. order is not needed for calculations, and AS doesn't > add to calculation query. Usually, :order rules are rather simple, but I had more complex ones, those, which include columns from related models. (config.list.sorting seems to allow sorting by columns of current model only) So having ability to have order on model level is rather important… > I could add unscope(:order) to calculation subquery > only to ensure it works for models with :order in default_scope I would be glad if you'll do so! :) At least, it would help me without making bad for anyone else. :) (as order isn't needed for calculations) > , however > unscope(:order) is a rails 4 method, and it would break rails 3.2 > compatibility, so it should be added only for rails 4. Well, may this fix go only to the master branch for rails 4. It would be useful just now for projects with new rails. > > El Miércoles, 18 de febrero de 2015 17:35:36 'Andrey Korobkov' via > ActiveScaffold : Ruby on Rails Gem escribió: > > Yes, I just have :order in my default_scope. > > My goal is to have records to be selected with :order for #list and #search, > > while without :order for list calculations. > > Could you see and advice any solution for this case (if it's possible at > > all)? > > > > Did you mean I should remove :order from default_scope > > (calculations will build unordered subquery, which is OK), > > then add needed :order clause in #custom_finder_options > > (#list and #search will use ordered query)? > > > > While it may be possible, I still hope there is a way to have :order on > > model level, rather than controller one… > > It's seems rather convenient to have models sorted by default, but some > > people think having :order in default_scope isn't a good idea; instead they > > propose to have a separate "ordered" scope. This should work for common > > rails apps, but what about AS? > > > > Also, why not just make calculation subquery to explicitly unscope(:order) > > from any previous scope? Is there any necessity in :order for calculations? > > MIN(), MAX(), SUM() and AVG() don't depend on order of their arguments… > > > > > > On Mon, 16 Feb 2015 09:15:07 +0100 > > > > Sergio Cambra <[email protected]> wrote: > > > There is no order i calculate_query so I guess you have set order in > > > beginning_of_chain. You could override custom_finder_options for that, > > > that > > > method is not used in calculate_query > > > > > > El Lunes, 9 de febrero de 2015 19:41:56 'Andrey Korobkov' via > > > ActiveScaffold :> > > > Ruby on Rails Gem escribió: > > > > Hello, again > > > > > > > > I've already made this work with unscope(:order) in default_scope, > > > > but order is still used in #calculate_query. > > > > https://github.com/activescaffold/active_scaffold/blob/master/lib/active > > > > _sca ffold/finder.rb#L423 > > > > > > > > Could you advice me a way to unscope it there? > > > > Also, could it be unscoped totally in calculations? > > > > Is ordering really necessary there? > > -- > You received this message because you are subscribed to the Google Groups > "ActiveScaffold : Ruby on Rails Gem" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/activescaffold. > For more options, visit https://groups.google.com/d/optout. -- Андрей Коробков -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/activescaffold. For more options, visit https://groups.google.com/d/optout.
pgpIl837zXfLz.pgp
Description: PGP signature
