Last active
August 12, 2023 15:22
-
-
Save ali-sheiba/74e7d1c0591c43f8e97b9ffff28d7bf0 to your computer and use it in GitHub Desktop.
Rails scaffold with Bootstrap 4
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
<div class="page-header"> | |
<div class="row"> | |
<div class="col"> | |
<%%= link_to "All <%= plural_table_name.capitalize %>", <%= index_helper %>_path, class: 'btn btn-default' %> | |
</div> | |
<div class="col text-right"> | |
<%%= link_to "Edit", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-primary' %> | |
</div> | |
</div> | |
<h1>Show <%= singular_table_name %></h1> | |
</div> | |
<dl class="dl-horizontal"> | |
<%- attributes.each do |attribute| -%> | |
<dt><%= attribute.human_name %>:</dt> | |
<dd><%%= @<%= singular_table_name %>.<%= attribute.name %> %></dd> | |
<%- end -%> | |
</dl> |
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
<h1>Edit <%= singular_table_name.capitalize %></h1> | |
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %> |
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
<div class="row"> | |
<div class="col-sm-6"> | |
<h1><%= plural_table_name.capitalize %></h1> | |
</div> | |
<div class="col-sm-6 text-right"> | |
<%%= link_to "Add New <%= human_name %>", new_<%= singular_table_name %>_path, class: 'btn btn-primary' %> | |
</div> | |
</div> | |
<div class="table-responsive"> | |
<table class="table table-hover"> | |
<thead> | |
<tr> | |
<%- attributes.each do |attribute| -%> | |
<th><%= attribute.human_name %></th> | |
<%- end -%> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
<%% @<%= plural_table_name%>.each do |<%= singular_table_name %>| %> | |
<%%= content_tag :tr, id: dom_id(<%= singular_table_name %>), class: dom_class(<%= singular_table_name %>) do %> | |
<%- attributes.each do |attribute| -%> | |
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td> | |
<%- end -%> | |
<td><%%= link_to 'Show', <%= singular_table_name %> %></td> | |
<%% end %> | |
<%% end %> | |
</tbody> | |
</table> | |
</div> |
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
<h1>New <%= singular_table_name %></h1> | |
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %> |
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
<div class="page-header"> | |
<div class="row"> | |
<div class="col"> | |
<%%= link_to "All <%= plural_table_name.capitalize %>", <%= index_helper %>_path, class: 'btn btn-default' %> | |
</div> | |
<div class="col text-right"> | |
<%%= link_to "Edit", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-primary' %> | |
</div> | |
</div> | |
<h1>Show <%= singular_table_name %></h1> | |
</div> | |
<dl class="dl-horizontal"> | |
<%- attributes.each do |attribute| -%> | |
<dt><%= attribute.human_name %>:</dt> | |
<dd><%%= @<%= singular_table_name %>.<%= attribute.name %> %></dd> | |
<%- end -%> | |
</dl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copied from https://github.com/excid3/jumpstart with minor changes
Place those files in
lib/templates/erb/scaffold
The index columns and form fields will be generated automatically from the scaffold command, example:
Or just
scaffold_controller