class Admin::<%= module_name_formatted.camelize%>Controller < Admin::ApplicationController belongs_to_app :<%= module_name_formatted %> add_breadcrumb '<%= module_name_formatted.humanize.titlecase %>', :admin_<%= module_name_formatted %>_path before_action :load_<%= module_name_formatted.singularize %>, only: [:show, :edit, :update, :destroy] def index @<%= module_name_formatted %> = <%= module_name_formatted.singularize.camelize %>.ordered.paginate(page: params[:page]) @<%= module_name_formatted %> = @<%= module_name_formatted %>.search(params[:search]) if params[:search] respond_with @<%= module_name_formatted %> end def show respond_with @<%= module_name_formatted.singularize %> end def new @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.new respond_with @<%= module_name_formatted.singularize %> end def create @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.new(<%= module_name_formatted.singularize %>_params) flash[:notice] = '<%= module_name_formatted.singularize.camelize %> created successfully' if @<%= module_name_formatted.singularize %>.save respond_with @<%= module_name_formatted.singularize %>, location: admin_<%= module_name_formatted %>_path end def edit respond_with @<%= module_name_formatted.singularize %> end def update if @<%= module_name_formatted.singularize%>.update_attributes(<%= module_name_formatted.singularize %>_params) flash[:notice] = '<%= module_name_formatted.singularize.camelize %> updated successfully' end respond_with @<%= module_name_formatted.singularize %>, location: admin_<%= module_name_formatted %>_path end def destroy flash[:notice] = '<%= module_name_formatted.singularize.camelize %> deleted successfully' if @<%= module_name_formatted.singularize %>.destroy respond_with @<%= module_name_formatted.singularize %>, location: admin_<%= module_name_formatted %>_path end private def load_<%= module_name_formatted.singularize %> @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.find_by!(id: params[:id]) end def <%= module_name_formatted.singularize %>_params params.require(:<%= module_name_formatted.singularize %>).permit(<%= attribute_names.collect{ |att| ":#{att}" }.join(', ') %>) end end