forked from heartcombo/simple_form
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add haml _form file and copy it into place if app template engine is …
…haml
- Loading branch information
1 parent
2a1b232
commit cbe2ddf
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
cbe2ddf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great! But I think there is a better way to get the template engine. You could do this:
And then it would retrieve from Rails::Generators.options by default. And then in the method:
:)
cbe2ddf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Learning the better/right way to get at some of this info was one of the motivations behind this. Thx for the tip on class_option--will be putting it in place next.