Hm yeah, that's a nice way to deal with it. I have another idea, how about using a form option to handle that instead?
class MyFormBuilder < SimpleForm::FormBuilder
def initialize(*)
super
@_skip_blank_attributes = options[:skip_blanks]
end
def input(attribute_name, *args, &block)
unless @_skip_blank_attributes && @object.send(attribute_name).blank?
super
end
end
end
So that you could use like this, with your form helper:
my_form_for @foo, skip_blanks: params[:action] == 'show'
This way you don't need to couple the form builder with the helper, and I think it's more flexible to add new conditions (you could use the helper instead of the params check here if necessary).
Completely untested, of course :)
Wdyt?