Class: DynamicAclsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/dynamic_acls_controller.rb

Instance Method Summary collapse

Instance Method Details

#setObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/dynamic_acls_controller.rb', line 10

def set
  @acl = Acl.where(params.require(:acl).permit(:object_type, :user_type, :state, :action, :user_id)).first
  if @acl.present?
    Acl.destroy(@acl.id)
  else
    @acl = Acl.create(params.require(:acl).permit(:object_type, :user_type, :state, :action, :user_id))
  end

  @object = params[:acl][:object_type].camelize.constantize
  @acls = Acl.where(object_type: @object.name).all
  
  render inline: rules
end

#showObject



3
4
5
6
7
8
# File 'app/controllers/dynamic_acls_controller.rb', line 3

def show
  @object = params[:id].camelize.constantize
  @acls = Acl.where(object_type: @object.name).all
  @rules = rules
  render inline: ERB.new(File.open("/#{__FILE__.split('controllers').first}views/index.erb").read).result(binding), type: 'text/html'
end