Class: Philtre::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/philtre-rails/philtre_model.rb

Defined Under Namespace

Classes: Model

Instance Method Summary collapse

Instance Method Details

#for_formObject



35
36
37
# File 'lib/philtre-rails/philtre_model.rb', line 35

def for_form
  Model.new filter_parameters.reject{|k,v| v.blank?}
end

#to_modelObject

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.



31
32
33
# 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