ruby on rails - Filterrific, scope without argument and check boxes -
i'm getting in filterrific, , find integration draper decorators , so.
but make simple request scope without parameter.
imagine model scope scope :unassigned, -> { where(support_user: nil)}
. can ticket.unassigned
perform query.
how integrate unparametred scope filterrific? "unassigned" check box example.
edit: form code:
<%= form_for_filterrific @filterrific |f| %> <%= f.hidden_field( :at_and_under_node_id,class: 'filterrific-periodically-observed') %> <%= f.label "unassigned" %> <%= f.check_box :unassigned, class: 'filterrific-periodically-observed' %> <%= link_to('reset filters',reset_filterrific_url) %> </div> <%# add automated spinner form when list refreshed %> <%= render_filterrific_spinner %> <% end %>
update: feature miss filter enums. if have
class ticket < activerecord::base enum status: [:wait, :closed, :deleted] ... end
and want make filter call ticket.wait
, how possible?
thank you!
use checkbox so:
<%= f.check_box "unassigned", class: 'filterrific-periodically-observed' %>
make sure unassigned
scope exists , added filterrific
directive in model.
then pass argument scope , check value:
scope :unassigned, ->(yes_or_no) { return nil if '0' == yes_or_no where(support_user: nil) }
Comments
Post a Comment