Sha256: 3c404201ad7ea059bc4650337487a63c0568e34c33e7d7b3ec3178d3141a1cea

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

class Admin::RoleSectionController < ApplicationController
  before_filter :login_required
  before_filter :the_role_require

  before_filter :the_role_find,     :only => [:destroy, :delete_policy]
  before_filter :the_role_object,   :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 the_role_find
    @role = Role.find(params[:role_id])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
the_role-1.4.1 app/controllers/admin/role_section_controller.rb
the_role-1.4.0 app/controllers/admin/role_section_controller.rb