Sha256: a0123b8334c33d83567a67586724108992e95352b65a95656b6314611f38ea76
Contents?: true
Size: 1.45 KB
Versions: 6
Compression:
Stored size: 1.45 KB
Contents
class <%= class_name %>Controller < Admin::AdminController before_filter :find_<%= sco_underscored %>, :only => [:show, :edit, :update, :destroy] <% if actions.include?('index') -%> def index @<%= sco_underscored_plural %> = <%= sco_class %>.all end <% end -%> def show end def new @<%= sco_underscored %> = <%= sco_class %>.new end def edit end def create @<%= sco_underscored %> = <%= sco_class %>.new(params[:<%= sco_underscored %>]) if @<%= sco_underscored %>.save flash[:notice] = '<%= sco_humanized_uc %> was successfully created.' redirect_to_form_referer else render :action => 'new' end end def update if @<%= sco_underscored %>.update_attributes(params[:<%= sco_underscored %>]) flash[:notice] = '<%= sco_humanized_uc %> was successfully updated.' redirect_to_form_referer else render :action => 'edit' end end def destroy @<%= sco_underscored %>.destroy redirect_to :back end <% if actions.include?('sort') -%> def sort params[:<%= sco_underscored %>].each_with_index do |id, index| <%= sco_class %>.update_all(['position=?', index+1], ['id=?', id]) end render :nothing => true end <% end -%> <% for action in non_restful_actions -%> def <%= action %> end <% end -%> private def find_<%= sco_underscored %> @<%= sco_underscored %> = <%= sco_class %>.find(params[:id]) end end
Version data entries
6 entries across 6 versions & 1 rubygems