Module: Routing::ItsfBackendResourceConcern

Extended by:
ActiveSupport::Concern
Defined in:
app/concerns/routing/itsf_backend_resource_concern.rb

Instance Method Summary collapse

Instance Method Details

#backend_resources(*args, &block) ⇒ Object

Using this method instead of resources, adds member routes for pages added in the itsf_backend configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/concerns/routing/itsf_backend_resource_concern.rb', line 7

def backend_resources(*args, &block)
  resources(*args, &block)

  # additional_member_actions = (Itsf::Backend::Configuration.default_resource_pages - [:show])

  # if additional_member_actions.any?
  #   resources_name = args.first
  #   resources resources_name, only: [] do
  #     member do
  #       additional_member_actions.each do |action|
  #         get action
  #       end
  #     end
  #   end
  # end

  additional_resource_route_blocks = Itsf::Backend::Configuration.additional_resource_route_blocks
  if additional_resource_route_blocks.any?
    resources_name = args.first
    additional_resource_route_blocks.each do |route_block|
      resources resources_name, only: [] do
        route_block.call(self)
      end
    end
  end
end