class Admin::NkuhtDonateDepartmentsController < OrbitAdminController def initialize super @app_title = 'nkuht_donate' end def index @nkuht_donate_departments = NkuhtDonateDepartment.all @url = admin_nkuht_donate_department_path(@nkuht_donate_departments) end def create @nkuht_donate_department = NkuhtDonateDepartment.new(nkuht_donate_department_params) @nkuht_donate_department.save redirect_to request.referer, :status => 303 end def create_in_form @nkuht_donate_department = NkuhtDonateDepartment.new(nkuht_donate_department_params) @nkuht_donate_department.save render :json => {:id=>@nkuht_donate_department.id.to_s, :title=>@nkuht_donate_department.title}.to_json ,:layout => false end def update @nkuht_donate_department = NkuhtDonateDepartment.find(params[:id]) @nkuht_donate_department.update_attributes(nkuht_donate_department_params) redirect_to request.referer, :status => 303 end def toggle @nkuht_donate_department = NkuhtDonateDepartment.find(params[:id]) @nkuht_donate_department.save! redirect_to request.referer, :status => 303 end def delete_departments departments = NkuhtDonateDepartment.find(params[:ids].split(',')) rescue nil if departments departments.each(&:destroy) end redirect_to request.referer, :status => 303 end private def nkuht_donate_department_params params.require(:nkuht_donate_department).permit! end end