Sha256: 91fc6b7e506b700a5b33bfdbb146d50aef3d3e2d64b656626d3bc10061445958

Contents?: true

Size: 980 Bytes

Versions: 49

Compression:

Stored size: 980 Bytes

Contents

require_dependency "para/application_controller"

module Para
  module Admin
    class FormResourcesController < Para::Admin::ResourcesController
      before_action :load_and_authorize_form
      after_action :attach_resource_to_component, only: [:create]

      # Include after resource loading to allow the concern to use the resource
      # in before_action hooks
      include Para::Admin::ResourceControllerConcerns

      private

      def attach_resource_to_component
        return unless resource.persisted?
        @component.resource = resource
        @component.save
      end

      def load_and_authorize_form
        loader = self.class.cancan_resource_class.new(
          self, :resource, parent: false, class: resource_model.name,
          singleton: true, through: :component, bypass_params_assignation: true
        )

        loader.load_and_authorize_resource
        instance_variable_set(:"@#{ resource_name }", @resource)
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
para-0.12.4 app/controllers/para/admin/form_resources_controller.rb
para-0.12.3 app/controllers/para/admin/form_resources_controller.rb
para-0.12.2 app/controllers/para/admin/form_resources_controller.rb
para-0.12.1 app/controllers/para/admin/form_resources_controller.rb
para-0.12.0 app/controllers/para/admin/form_resources_controller.rb
para-0.11.4 app/controllers/para/admin/form_resources_controller.rb
para-0.11.3 app/controllers/para/admin/form_resources_controller.rb
para-0.11.2 app/controllers/para/admin/form_resources_controller.rb
para-0.11.1 app/controllers/para/admin/form_resources_controller.rb
para-0.11.0 app/controllers/para/admin/form_resources_controller.rb
para-0.10.0 app/controllers/para/admin/form_resources_controller.rb
para-0.9.4 app/controllers/para/admin/form_resources_controller.rb
para-0.9.3.3 app/controllers/para/admin/form_resources_controller.rb
para-0.9.3.2 app/controllers/para/admin/form_resources_controller.rb
para-0.9.3.1 app/controllers/para/admin/form_resources_controller.rb
para-0.9.2 app/controllers/para/admin/form_resources_controller.rb
para-0.9.0 app/controllers/para/admin/form_resources_controller.rb
para-0.8.15 app/controllers/para/admin/form_resources_controller.rb
para-0.8.14 app/controllers/para/admin/form_resources_controller.rb
para-0.8.13 app/controllers/para/admin/form_resources_controller.rb