我正在使用带有元搜索的Active Admin。我有一个habtm关系,但连接表不是默认的。我有
class Person < ActiveRecord::Base
has_and_belongs_to_many :events, :join_table => 'events_staff'
end
class Event < ActiveRecord::Base
has_and_belongs_to_many :staff, :class_name => 'Person', :join_table => 'events_staff'
end
当我使用主动管理员时,我想要的是:
ActiveAdmin.register Person do
filter :events, :join_table => 'events_staff'
end
重命名模型不是一种选择。我该怎么做?
答案 0 :(得分:1)
好的这个问题:How do I do multiple has_and_belongs_to_many associations between the same two classes?给了我一个在Person模型中重命名我的关系的策略。所以现在我有:
class Person < ActiveRecord::Base
has_and_belongs_to_many :staffed_events, :join_table => 'events_staff', :class_name => 'Event'
end
我的过滤器是filter:staffed_events