Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
= form_with(model: @<%= model_resource_name %>) do |form|
- if @<%= singular_table_name %>.errors.any?
div style="color: red"
h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
ul
- @<%= singular_table_name %>.errors.each do |error|
li = error.full_message
<% attributes.each do |attribute| -%>
div
<% if attribute.password_digest? -%>
= form.label :password, style: "display: block"
= form.password_field :password
div
= form.label :password_confirmation, style: "display: block"
= form.password_field :password_confirmation
<% elsif attribute.attachments? -%>
= form.label :<%= attribute.column_name %>, style: "display: block"
= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
<% else -%>
= form.label :<%= attribute.column_name %>, style: "display: block"
= form.<%= attribute.field_type %> :<%= attribute.column_name %>
<% end -%>
<% end -%>
div[class="#{btn_submit}"]
= form.submit
div.w-full
h1.font-bold.text-2xl Editing <%= human_name.capitalize %>
div.flex.gap-8
= link_to icon('fas fa-eye',"Show <%= human_name.capitalize %>"), <%= edit_helper(type: :path) %>, class:"#{btn_sm_green}"
= link_to icon('fas fa-list',"List <%= human_name.pluralize.capitalize %>"),
<%= index_helper(type: :path) %>, class:"#{btn_sm_green}"
= button_to icon('fas fa-trash',"Destroy <%= human_name.capitalize %>"), <%= model_resource_name(prefix: "@") %>, method: :delete, form:{data: { turbo_confirm: 'Are you sure?', turbo_method:'delete' }}, class:"#{btn_sm} bg-red-700 text-white"
hr.border-1.border-blue-500.my-1
== render "form", <%= singular_table_name %>: @<%= singular_table_name %>
div.w-full
p style="color: green" = notice
h1.font-bold.text-2xl <%= human_name.pluralize %>
= link_to link_to icon('fas fa-plus-square', "New <%= human_name.capitalize %>"), <%= new_helper(type: :path) %>,class:"#{btn_sm_blue}"
hr.border-1.border-blue-500.my-1
#<%= plural_table_name %>
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
== render <%= singular_table_name %>
= link_to icon('fas fa-eye',"Show <%= human_name.capitalize %>"), <%= model_resource_name(singular_table_name) %>,class:"#{btn_sm_green}"
= link_to icon('fas fa-edit',"Edit <%= human_name.capitalize %>"), edit_<%= singular_table_name %>_path(<%= singular_table_name %>),class:"#{btn_sm_green}"
hr.border-1.border-blue-500.my-1
div.w-full
h1.font-bold.text-2xl New <%= human_name.capitalize %>
div = link_to icon('fas fa-list',"Cancel - List <%= human_name.pluralize.capitalize %>"), <%= index_helper(type: :path) %>, class:"#{btn_sm_green}"
hr.border-1.border-blue-500.my-1
== render "form", <%= singular_table_name %>: @<%= singular_table_name %>
div id="#{dom_id <%= singular_name %>}"
<% attributes.reject(&:password_digest?).each do |attribute| -%>
p
strong.w-40.inline-block.text-right <%= attribute.human_name %>:
<% if attribute.attachment? -%>
= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached?
<% elsif attribute.attachments? -%>
- <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>|
div
= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>
<% else -%>
=< <%= singular_name %>.<%= attribute.column_name %>
<% end -%>
<% end -%>
div.w-full
p style="color: green" = notice
h1.font-bold.text-2xl Showing <%= human_name.capitalize %>
div.flex.gap-8
=> link_to icon('fas fa-edit',"Edit <%= human_name.capitalize %>"), <%= edit_helper(type: :path) %>, class:"#{btn_sm_green}"
=< link_to icon('fas fa-list',"List <%= human_name.pluralize.capitalize %>"), <%= index_helper(type: :path) %>, class:"#{btn_sm_green}"
= button_to icon('fas fa-trash',"Destroy <%= human_name.capitalize %>"), <%= model_resource_name(prefix: "@") %>, method: :delete, form:{data: { turbo_confirm: 'Are you sure?', turbo_method:'delete' }}, class:"#{btn_sm} bg-red-700 text-white"
hr.border-1.border-blue-500.my-1
== render @<%= singular_table_name %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment