Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

associated_collection_scope order / sort #2430

Open
AlexKlim opened this issue Oct 12, 2015 · 3 comments
Open

associated_collection_scope order / sort #2430

AlexKlim opened this issue Oct 12, 2015 · 3 comments

Comments

@AlexKlim
Copy link

Hi.
How can I reorder or sort the associated collection scope ?

I tried

field :some_fields do
  orderable true
  associated_collection_scope do
    Proc.new do |scope|
      scope = scope.reorder('some_table_names.some_table_column ASC')
    end
  end
end

But it doesn't work for me. Any ideas ?
Thanks.

@yourivdlans
Copy link

I'm also looking for a nice solution to this problem. Right now I've resorted to a default_scope { order :field }.

@louman
Copy link

louman commented Jan 16, 2017

One thing you can do is scope the list action of the model.

For instance, in my case, I had a model called Post which belongs_to Venue. The solution for me was to sort the list by name:

config.model 'Venue' do
  list do
    sort_by :name
  end
end

@sasselin
Copy link

Why do not use associated_collection_scope for order?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants