1
我正在使用我的Rails應用程序中的ransack
gem進行高級搜索。我怎樣才能篩選attribute_select
方法不顯示某些領域,如id
和created_at
等Rails - Ransack - 自定義屬性_select
= f.attribute_fields do |a|
= a.attribute_select
我目前的方法,上面羅列了任何和所有屬性。
我正在使用我的Rails應用程序中的ransack
gem進行高級搜索。我怎樣才能篩選attribute_select
方法不顯示某些領域,如id
和created_at
等Rails - Ransack - 自定義屬性_select
= f.attribute_fields do |a|
= a.attribute_select
我目前的方法,上面羅列了任何和所有屬性。
根據Why your Ruby class macros (might) suck (mine did):
def self.ransackable_attributes(auth_object = nil)`
super - ['id', 'created_at']`
end
您還可以定義搜索的屬性與指定像這樣的非搜索者:
def self.ransackable_attributes(auth_object = nil)
%w(searchable_attribute_goes_here another_one_goes_here ...) + _ransackers.keys
end