class Admin::<%= module_name_formatted.camelize%>Controller < Admin::ApplicationController before_filter :load_<%= module_name_formatted.singularize %>, :only => [:show, :edit, :update, :destroy] belongs_to_spud_app :<%= module_name_formatted %> add_breadcrumb "<%= module_name_formatted.humanize.titlecase %>", :admin_<%= module_name_formatted %>_path def index @<%= module_name_formatted %> = <%= module_name_formatted.singularize.camelize %>.paginate(:page => params[:page]) respond_with @<%= module_name_formatted %> end def show respond_with @<%= module_name_formatted %> 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 %>.where(:id => params[:id]).first if @<%= module_name_formatted.singularize %>.blank? flash[:error] = "Could not find the requested <%= module_name_formatted.singularize.camelize %>" redirect_to admin_<%= module_name_formatted %>_path return false end end def <%= module_name_formatted.singularize %>_params params.require(:<%= module_name_formatted.singularize %>).permit(<%= attribute_names.collect{ |att| ":#{att}" }.join(', ') %>) end end