class <%= class_name %>Controller < ApplicationController <% if "new".in? actions %> def new build_<%= resource %> end <% end -%> <% if "create".in? actions %> def create build_<%= resource %> @<%= resource %>.save end <% end -%> <% if "edit".in? actions %> def edit load_<%= resource %> build_<%= resource %> end <% end -%> <% if "update".in? actions %> def update load_<%= resource %> build_<%= resource %> @<%= resource %>.save end <% end -%> <% if "show".in? actions %> def show load_<%= resource %> end <% end -%> <% if "destroy".in? actions %> def destroy load_<%= resource %> @<%= resource %>.destroy end <% end -%> <% unless actions.empty? %> private <% end -%> <% unless actions == %w(destroy) %> def build_<%= resource %> @<%= resource %> ||= <%= class_name %>.new @<%= resource %>.attributes = <%= resource %>_params end <% end -%> <% if (actions & %w(edit update show destroy)).any? %> def load_<%= resource %> @<%= resource %> = <%= class_name %>.find params[:id] end <% end -%> <% unless actions == %w(destroy) %> def <%= resource %>_params params.fetch(:<%= singular_table_name %>, {}).permit() end <% end -%> end