Automating form creation

Hi! I want to auto-select the form method in my form creator to automate
the creation of forms. Do you know any better way to do this? :

(I want a better solution for this: form_method f, @resource, attribute
)

The erb form:

<% form_for(:resource,
:url => resource_path,
:html => { :method => :put }) do |f| %>

<% resource_columns.each_with_index do |attribute, index| -%>

<%= resource_titles[index] -%>
<%= form_method f, @resource, attribute -%>

<% end -%>

<% end -%>

The helper:

This Helper returns the apropiate form method

for the resource and attribute

def form_method form, resource, attribute

case resource.column_for_attribute(attribute).type

when :string      : form.text_field(attribute)
when :text        : form.text_area(attribute)
when :integer     : form.text_field(attribute)
when :float       : form.text_field(attribute)
when :decimal     : form.text_field(attribute)
when :datetime    : form.text_field(attribute)
when :timestamp   : form.text_field(attribute)
when :time        : form.text_field(attribute)
when :date        : form.text_field(attribute)
when :binary      : form.check_box(attribute)
when :boolean     : form.check_box(attribute)

end

end

Thanks!

emmanueloga.blogspot.com