-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
sort_link on polymorphic association but with multiple model #782
Comments
This issue appears more to be a HOW-TO issue rather than a bug in Ransack. We are in the process of cleaning up the Ransack gem and repo. If this issue is still relevant could you please ask it on StackOverflow? If you think it is an issue with Ransack, please provide a repo with the issue and / or a pull request with failing tests. If you don't know how to do this, indicate it in the issue and we will look into it eventually. Thank you https://github.com/activerecord-hackery/ransack/blob/master/CONTRIBUTING.md |
@dipaktc I am also facing that same issue. Any solution for this issue? |
I'm running into the same blocker, but with the added complexity of having different attribute names in the different associations. I have a Notification with a polymorphic 'originator' that can be a Person, Group, or Channel. Person has 'last_name', while Group and Channel have 'name'. I can sort via both of these sort_links: However, I cannot sort by: |
I have following polymorphic relationship
class Offer < ApplicationRecord
belongs_to :offerable, polymorphic: true
end
class Company < ApplicationRecord
has_many :offers, as: :offerable, dependent: :destroy
end
class Location < ApplicationRecord
has_many :offers, as: :offerable, dependent: :destroy
end
Now Offers are offerable with either Company or Location.
In the both tables (Company, Location), name field is there in the database.
= sort_link(query, :offerable_of_Company_type_name) do
%span{ class: ["btn btn-outline-success btn-sm", ('active' if params[:name])] } Name
Above code is working but I want to search with Company name as well as Location name so I will try below
= sort_link(query, :offerable_of_Company_type_name_or_offerable_of_Location_type_name_cont, 'name') do
%span{ class: ["btn btn-outline-success btn-sm", ('active' if params[:name])] } Name
But Now, above code is not working. So how can I sort with two fields for offerable. I want to sort with Company name as well as Location name.
The text was updated successfully, but these errors were encountered: