Hi, Did you read documentation about sort and sort_by at: https://github.com/activescaffold/active_scaffold/wiki/API%3A-Column ??
-- Volker On 18 Jun., 01:52, patrick <[email protected]> wrote: > Hi, > > So, I have run into a bit of a problem.. In my active scaffold list, > I have added some virtual attributes on my model, and have those being > displayed... Since they are not real columns in the database, > activescaffold does not allow them to be sorted by (completely > understandable). > > This was a bit of a problem, but I saw the method "beginning_of_chain" > could override and potentially solve this problem... So I made a > scope in the model which performs a bit of a complex query using a > chained combination of select, join, where, and order. However, I > quickly saw that when doing this, the order_clause is not being > detected in active scaffold... > > I am not quite sure why this is, because I couldn't quite understand > what the current_scoped_methods in active record is doing, and why > that is returning nil... The query does have the text in it "ORDER > BY"... > > So I have a feeling something in this code needs to be adjusted: > > module ActiveScaffold::DataStructures > # encapsulates the column sorting configuration for the List view > class Sorting > # ... > def set_default_sorting(model) > model_scope = model.send(:current_scoped_methods) > order_clause = model_scope.arel.order_clauses.join(",") if > model_scope > > # If an ORDER BY clause is found set default sorting according > to it, else > # fallback to setting primary key ordering > if order_clause > set_sorting_from_order_clause(order_clause, model.table_name) > @default_sorting = true > else > set(model.primary_key, 'ASC') if model.column_names.include? > (model.primary_key) > end > end > > .... > > Can anyone give me some advice on how to solve this? > > -patrick -- 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.
