Module: ActionView::Helpers::MagicFormHelper

Extended by:
ActiveSupport::Concern
Includes:
FormHelper
Defined in:
lib/magic_form.rb

Instance Method Summary collapse

Instance Method Details

#magic_form(*resources) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/magic_form.rb', line 10

def magic_form(*resources)
  options = resources.extract_options!
  resource = resources.last
  attributes = resource.attribute_names - ["created_at", "updated_at"]

  form_for(resources) do |f|
    attributes.each do |attribute|
      concat(f.label attribute, options[attribute.to_sym])
      concat(f.text_field attribute)
    end
    concat(f.submit)
  end
end