Skip to content

Instantly share code, notes, and snippets.

@dabit
Created December 2, 2010 00:01
Show Gist options
  • Save dabit/724490 to your computer and use it in GitHub Desktop.
Save dabit/724490 to your computer and use it in GitHub Desktop.
magic form
def magic_form(*resources)
options = resources.extract_options!
resource = resources.last
attributes = resource.attribute_names - [:created_at, :updated_at]
form_for(resource) do |f|
attributes.each do |attribute|
concat(f.label(attribute, (options[attribute.to_sym] || attribute)))
concat(f.text_field(attribute))
end
concat(f.submit)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment