Sha256: 4b7749d58cc9f622e0d47ada967e3e81ebcc7602c2191305e5c94e4de8ff9ff8

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

class Admin::RoleSectionController < ApplicationController
  before_filter :login_required
  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

2 entries across 2 versions & 1 rubygems

Version Path
the_role-1.3.1 app/controllers/admin/role_section_controller.rb
the_role-1.3.0 app/controllers/admin/role_section_controller.rb