Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change scaffold to use _form as partial and div's instead of paragrap…
…hs. [#1760 status:resolved]
- Loading branch information
Showing
6 changed files
with
25 additions
and
31 deletions.
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
17 changes: 17 additions & 0 deletions
17
railties/lib/generators/erb/scaffold/templates/_form.html.erb
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
<%% form_for(@<%= singular_name %>) do |f| %> | |||
<%%= f.error_messages %> | |||
|
|||
<% for attribute in attributes -%> | |||
<div class="attribute"> | |||
<%%= f.label :<%= attribute.name %> %><br /> | |||
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> | |||
</div> | |||
<% end -%> | |||
<div class="action"> | |||
<%% if @<%= singular_name %>.new_record? %> | |||
<%%= f.submit 'Create' %> | |||
<%% else %> | |||
<%%= f.submit 'Update' %> | |||
<%% end %> | |||
</div> | |||
<%% end %> |
16 changes: 2 additions & 14 deletions
16
railties/lib/generators/erb/scaffold/templates/edit.html.erb
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,18 +1,6 @@ | |||
<h1>Editing <%= singular_name %></h1> | <h1>Editing <%= singular_name %></h1> | ||
|
|
||
<%% form_for(@<%= singular_name %>) do |f| %> | <%%= render 'form' %> | ||
<%%= f.error_messages %> | |||
|
|||
<% for attribute in attributes -%> | |||
<p> | |||
<%%= f.label :<%= attribute.name %> %><br /> | |||
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> | |||
</p> | |||
<% end -%> | |||
<p> | |||
<%%= f.submit 'Update' %> | |||
</p> | |||
<%% end %> | |||
|
|
||
<%%= link_to 'Show', @<%= singular_name %> %> | | <%%= link_to 'Show', @<%= singular_name %> %> | | ||
<%%= link_to 'Back', <%= plural_name %>_path %> | <%%= link_to 'Back', <%= plural_name %>_path %> |
16 changes: 2 additions & 14 deletions
16
railties/lib/generators/erb/scaffold/templates/new.html.erb
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,17 +1,5 @@ | |||
<h1>New <%= singular_name %></h1> | <h1>New <%= singular_name %></h1> | ||
|
|
||
<%% form_for(@<%= singular_name %>) do |f| %> | <%%= render 'form' %> | ||
<%%= f.error_messages %> | |||
|
|
||
<% for attribute in attributes -%> | <%%= link_to 'Back', <%= plural_name %>_path %> | ||
<p> | |||
<%%= f.label :<%= attribute.name %> %><br /> | |||
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> | |||
</p> | |||
<% end -%> | |||
<p> | |||
<%%= f.submit 'Create' %> | |||
</p> | |||
<%% end %> | |||
|
|||
<%%= link_to 'Back', <%= plural_name %>_path %> |
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
5d645c2
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.
why not "render f" instead of render 'form' ??
5d645c2
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.
because form is the partial's name?
5d645c2
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.
jerome, unless I'm missing something, it's because there is no 'f' object to render. "render 'form'" will render the "_form.html.erb"
5d645c2
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.
I actually use "render f" more often. Keep form_for in the template and only put the fields in the _form partial.
5d645c2
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.
i agree then. keeping the form_for and doing render f.
5d645c2
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.
Oh, how I love the divs ... Thanks José! :-)
5d645c2
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.
w00t!