class <%= controller_class_name %>Controller < <%= controller_class_path.map(&:camelize).join('::') %>::BaseController
before_action :set_<%= singular_name %>, only: [:show, :edit, :update, :destroy] def index @<%= plural_name %> = <%= class_name %>.page(params[:page]) end def new @<%= singular_name %> = <%= orm_class.build(class_name) %> end def create @<%= singular_name %> = <%= orm_class.build(class_name, "#{singular_name}_params") %> if @<%= orm_instance(singular_name).save %> redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully created.'" %> else render :new end end def show end def edit end def update if @<%= orm_instance(singular_name).update("#{singular_name}_params") %> redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully updated.'" %> else render :edit end end def destroy @<%= orm_instance(singular_name).destroy %> redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %> end private def set_<%= singular_name %> @<%= singular_name %> = <%= orm_class.find(class_name, "params[:id]") %> end def <%= "#{singular_name}_params" %> params.fetch(:<%= singular_name %>, {}).permit(
<% attributes_names.map do |name| -%>
<%= ":#{name}," %>
<% end -%>
) end
end