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

Consider ransack aliases when sorting #766

Closed

Conversation

faragorn
Copy link
Contributor

ransack_alias is a great feature however it does not work with sorting out of the box. In my opinion ransack_aliases should be recognized by sort function out of the box.

Consider the following example:

class Post < ActiveRecord::Base
  belongs_to :author

  # Abbreviate :author_first_name_or_author_last_name to :author
  ransack_alias :author, :author_last_name
end

In your view:

  <%= sort_link(@q, :author, 'Author Name') %>

@faragorn faragorn force-pushed the ransack_alias_sorting branch from 0e14f02 to 666742c Compare February 14, 2017 19:14
@scarroll32
Copy link
Member

Hi @faragorn this looks good and should merge now we not supporting Ruby 2. Could you write some tests to cover this before it is merged?

@ekampp
Copy link

ekampp commented Nov 5, 2019

Hey, @seanfcarroll, I need this feature, so if you could help me understand, where I should start attempting to add test coverage, I will open a new PR with this code and test coverage. Thanks.

@deivid-rodriguez
Copy link
Contributor

Closing as this was fixed by #1223.

@faragorn Unfortunately you were not credited as commit author even if you are the original author of this solution, I will add your name to the changelog though! Thanks!

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

Successfully merging this pull request may close these issues.

4 participants