class <%= class_name %>Controller < Admin::AdminController before_filter :find_<%= sco_underscored %>, :only => [<%= filter_actions %w( show edit update destroy) %>] before_filter :find_<%= sco_parent_underscored %>, :only => [<%= filter_actions %w( index new create) %>] before_filter :titles, :except => [<%= filter_actions %w( destroy sort ) %>] <% if actions.include?('index') -%> def index @<%= sco_underscored_plural %> = @<%= sco_parent_underscored %>.<%= sco_underscored_plural %> end <% end -%> <% if actions.include?('show') -%> def show end <% end -%> <% if actions.include?('new') -%> def new @<%= sco_underscored %> = @<%= sco_parent_underscored %>.<%= sco_underscored_plural %>.build end <% end -%> <% if actions.include?('edit') -%> def edit end <% end -%> <% if actions.include?('create') -%> def create @<%= sco_underscored %> = @<%= sco_parent_underscored %>.<%= sco_underscored_plural %>.build(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 <% end -%> <% if actions.include?('update') -%> 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 <% end -%> <% if actions.include?('destroy') -%> def destroy @<%= sco_underscored %>.destroy redirect_to :back end <% end -%> <% if actions.include?('sort') -%> def sort params[:<%= sco_underscored_plural %>].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_parent_underscored %> @<%= sco_parent_underscored %> = <%= sco_parent_class %>.find(params[:<%= sco_parent_underscored %>_id]) end def find_<%= sco_underscored %> @<%= sco_underscored %> = <%= sco_class %>.find(params[:id]) end def titles add_breadcrumb '<%= sco_parent_titleized_plural %>', admin_<%= sco_parent_underscored_plural %>_path add_breadcrumb @<%= sco_parent_underscored %> add_breadcrumb '<%= sco_titleized_plural %>' add_breadcrumb @<%= sco_underscored %> end end