10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/magic_form.rb', line 10
def magic_form(*resources)
form_content = ""
form_eval = []
out = ""
options = resources.
resource = resources.last
resource.attribute_names.each do |attribute|
unless attribute == "created_at" || attribute == "updated_at"
form_eval << "f.label '#{options[attribute.to_sym] || attribute.to_sym}'"
form_eval << "f.text_field :#{attribute}"
end
end
form_eval << "f.submit '#{options[:submit] || 'submit' }'"
out = form_for resource do |f|
form_eval.each do |c|
form_content << "#{eval(c)}"
end
form_content
end
out
end
|