activeadmin - Filter by association in ruby on rails using active admin gem -


i have 2 models: login , account

class login   belongs_to :account   attr_accessible: first_name, primary_admin # primary_admin boolean end  class account  has_many: logins   def primary_admin   @primary_admin ||= self.logins.find { |l| l.primary_admin }  end end 

so in resume account has many logins, there 1 login primary_admin = true. in filters of account want search login (the 1 primary_admin = true) using first_name of login.

using active admin in app/admin/account.rb have this

filter :primary_admin, as: :string 

but not working, appreciated, in advance!

here database schema:

login

id             :integer(4)      not null, primary key email          :string(255)     default(""), not null first_name     :string(255) last_name      :string(255) primary_admin  :boolean(1) account_id     :integer(4) 

account

id              :integer(4)      not null, primary key name            :string(255) 

try if primary_admin string field

activeadmin.register account   filter :primary_admin, as: => :string end  activeadmin.register login   filter :account_primary_admin, as: => :string end 

or try if primary_admin boolean field

activeadmin.register account   filter :primary_admin, :as => :select end  activeadmin.register login   filter :account_primary_admin, :as => :select end 

and might have remove this

def primary_admin   @primary_admin ||= self.logins.find { |l| l.primary_admin } end 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -