Class: LesliVault::Role::DescriptorsController
- Inherits:
-
ApplicationController
- Object
- Lesli::ApplicationLesliController
- ApplicationController
- LesliVault::Role::DescriptorsController
- Defined in:
- app/controllers/lesli_vault/role/descriptors_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /role/descriptors.
-
#destroy ⇒ Object
DELETE /role/descriptors/1.
- #index ⇒ Object
Instance Method Details
#create ⇒ Object
POST /role/descriptors
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/lesli_vault/role/descriptors_controller.rb', line 44 def create role_descriptor_status = false system_descriptor = Descriptor.find_by(:id => role_descriptor_params[:id]) role_descriptor = @role.descriptors.with_deleted.find_by(:descriptor => system_descriptor) if not role_descriptor role_descriptor = @role.descriptors.new(:descriptor => system_descriptor) role_descriptor_status = role_descriptor.save elsif role_descriptor.deleted? role_descriptor_status = role_descriptor.recover end if role_descriptor_status #Role::Activity.log_create_descriptor(current_user, @role, role_descriptor) respond_with_successful(role_descriptor) else respond_with_error(role_descriptor.errors..to_sentence) end end |
#destroy ⇒ Object
DELETE /role/descriptors/1
67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/lesli_vault/role/descriptors_controller.rb', line 67 def destroy return respond_with_not_found unless @role_descriptor if @role_descriptor.destroy Role::Activity.log_destroy_descriptor(current_user, @role, @role_descriptor) respond_with_successful else respond_with_error(@role_descriptor.errors..to_sentence) end end |
#index ⇒ Object
39 40 41 |
# File 'app/controllers/lesli_vault/role/descriptors_controller.rb', line 39 def index respond_with_successful(Role::Descriptor.index(current_user, @query, @role)) end |