How to write filters for methods (not fields) in Active Admin? -
i have active admin index page resource.
activeadmin.register request index column :created_at column :content column "approved", :approved? default_actions end filter :created_at filter :content filter :approved? end the problem doesn't generate filter approved? request (but generates column properly). think it's because approved method , returns true if approved_at isn't nil. how can write filter in case?
try create filter button using scopes:
# model/request.rb scope :approved, where("approved_at not null") # or...if have other default values on approved_at column can try scope :approved, where("approved not", nil) scope :approved, where("approved not ?", "") #app/admin/requests.rb scope :approved some more info on scopes in active admin: http://activeadmin.info/docs/2-resource-customization.html#scoping_the_queries
Comments
Post a Comment