Using the ActiveAttr
:
class Filter
include ActiveAttr::Model
attribute term
# Overriding to_key, to_param, model_name, param_key etc doesn't help :(
end
class SpecialFilter < Filter
end
How do I override the ActiveModel to generate the (same) predefined input names for all subclasses?
= form_for SpecialFilter.new, url: 'xx' do |f|
= f.text_field :term
So instead of <input name='special_filter[term]' />
I need to get <input name='filter[term]' />
NOTE: The scenario is way much more complicated (with simple_form and radios/checkboxes/dropdowns etc), so please do not suggest to change the name of the class or similar workarounds. I really do need to have the consistent name to be used by the form builder.