Answer the question
In order to leave comments, you need to log in
Why don't ransortable_attributes and ransackable_associations work in the ransack gem?
I am using ransortable_attributes to set the attributes available for sorting. But she doesn't work. That is, the attributes specified in ransackable_attributes are still available for sorting. How to do it right?
Second question.
I am setting associations through the ransortable_attributes function. But in the form in the attribute_select function, the associations are not displayed. They are only displayed if they are specified explicitly. For example like this:
s.attribute_select associations: [:information, :setting]
s.attribute_select associations: [:information, :setting], class: 'form-control'
s.attribute_select Hash.new, class: 'form-control'
class User < ActiveRecord::Base
# some code
def self.ransackable_attributes(auth_object = nil)
%w(
email
current_sign_in_ip
last_sign_in_ip
created_at
updated_at
)
end
def self.ransortable_attributes(auth_object = nil)
%w(
email
created_at
updated_at
)
end
def self.ransackable_associations(auth_object = nil)
%w(
information
setting
)
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question