Sha256: d78e73f23a432316f65111d559408f9487a81a0006b371ae8e1905d320da933c

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 :the_owner_require, :only=>[:destroy, :delete_policy]
  before_filter :find_role, :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.0 app/controllers/admin/role_section_controller.rb