From 26cae80700ec58b2f4d2db831b0169fcaf039803 Mon Sep 17 00:00:00 2001 From: Masayuki Ueda Date: Wed, 8 Nov 2017 17:38:00 +0900 Subject: [PATCH] enable form_with if rails 5.1+ --- lib/generators/haml/scaffold/templates/_form.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/generators/haml/scaffold/templates/_form.html.haml b/lib/generators/haml/scaffold/templates/_form.html.haml index 993cd03..d1b033e 100644 --- a/lib/generators/haml/scaffold/templates/_form.html.haml +++ b/lib/generators/haml/scaffold/templates/_form.html.haml @@ -1,4 +1,8 @@ +<% if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 1 -%> += form_with model: @<%= singular_table_name %>, local: true do |f| +<% else -%> = form_for @<%= singular_table_name %> do |f| +<% end -%> - if @<%= singular_table_name %>.errors.any? #error_explanation %h2= "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"