Sha256: f33b3b08c1d9c3a85376b109fee6e7ffc1020756b1eaa0eeddf118c335074983

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class Admin::RoleSectionController < ApplicationController
  before_filter :the_role_require
  before_filter :find_role, :only=>[:destroy, :delete_policy]
  before_filter :the_owner_require, :only=>[:destroy, :delete_policy]
  
  def destroy
    section_name = params[:id]
    role = TheRole.get(@role.the_role)
    role.delete(section_name.to_sym)

    if @role.update_attributes({:the_role => role.to_yaml})
      flash[:notice] = t('the_role.section_deleted')
      redirect_to edit_admin_role_path(@role)
    else
      render :action => :edit
    end   
  end#destroy
  
  def delete_policy
    section_name = params[:id]
    policy_name = params[:name]
    role = TheRole.get(@role.the_role)
    role[section_name.to_sym].delete(policy_name.to_sym)
    
    if @role.update_attributes({:the_role => role.to_yaml})
      flash[:notice] = t('the_role.section_policy_deleted')
      redirect_to edit_admin_role_path(@role)
    else
      render :action => :edit
    end
  end#delete_policy

  protected

  def find_role
    @role = Role.find(params[:role_id])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
the_role-1.2.1 app/controllers/admin/role_section_controller.rb