我在我的 Rails 应用程序中使用 Ransack gem。它按预期工作,但是如何在属性选择的下拉框中重新排序属性列表?对我来说不幸的是,用户的“姓名”在列表的底部附近,而理想情况下它会在顶部。
.field
= f.attribute_fields do |a|
= a.attribute_select associations: [:terms, :contact_informations, :educational_experiences, :home_towns, :local_residences, :permanent_addresses, :emergency_contact_informations]
以上是我当前的属性选择,现在它列出了所有用户属性,然后是每个关联的属性。在我的模型中,我使用以下内容过滤掉一些属性。
def self.ransackable_attributes(auth_object = nil)
super - ['id', 'first_name', 'middle_name', 'last_name', 'created_at', 'updated_at', 'encrypted_password', 'reset_password_token', 'reset_password_sent_at', 'remember_created_at',
'sign_in_count', 'current_sign_in_at', 'last_sign_in_at', 'current_sign_in_ip', 'last_sign_in_ip']
end