class Philtre::Filter

Public Instance Methods

for_form() click to toggle source
# File lib/philtre-rails/philtre_model.rb, line 35
def for_form
  Model.new filter_parameters.reject{|k,v| v.blank?}
end
to_model() click to toggle source

TODO If your model does not act like an Active Model object, then you should define :to_model yourself returning a proxy object that wraps your object with Active Model compliant methods.

07-May-2014 Nice idea, except that (at least from 4.0.2) rails uses to_model only in some cases to get naming, and the original object gets passed to the FormBuilder. Which is a bit stoopid.

# File lib/philtre-rails/philtre_model.rb, line 31
def to_model
  raise "Use for_form, you can't pass #{self} directly into a form_for call."
end