add haml _form file and copy it into place if app template engine is haml

This commit is contained in:
Jack Dempsey 2010-07-14 01:26:29 +08:00 committed by José Valim
parent 2a1b232c28
commit df6ec5ea66
2 changed files with 23 additions and 1 deletions

View File

@ -13,7 +13,11 @@ module SimpleForm
end
def copy_scaffold_template
copy_file '_form.html.erb', 'lib/templates/erb/scaffold/_form.html.erb'
if Rails::Generators.options[:rails][:template_engine] == :haml
copy_file '_form.html.haml', 'lib/templates/haml/scaffold/_form.html.haml'
else
copy_file '_form.html.erb', 'lib/templates/erb/scaffold/_form.html.erb'
end
end
end
end

View File

@ -0,0 +1,18 @@
= simple_form_for(@<%= singular_name %>) do |f|
- if @<%= singular_name %>.errors.any?
#error_explanation
%h2
= pluralize(@<%= singular_name %>.errors.count, "error")
prohibited this <%= singular_name %> from being saved:
%ul
- @<%= singular_name %>.errors.full_messages.each do |msg|
%li= msg
.inputs
<%- attributes.each do |attribute| -%>
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
<%- end -%>
.actions
= f.button :submit