Module: Para::Component::CrudDecorator

Includes:
BaseDecorator
Defined in:
app/decorators/para/component/crud_decorator.rb

Instance Method Summary collapse

Instance Method Details

#path(options = {}) ⇒ Object



6
7
8
9
# File 'app/decorators/para/component/crud_decorator.rb', line 6

def path(options = {})
  options[:model] ||= model_singular_route_key
  find_path([:admin, self, :resources], options)
end

#relation_path(controller_or_resource, *nested_resources, **options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/decorators/para/component/crud_decorator.rb', line 11

def relation_path(controller_or_resource, *nested_resources, **options)
  id_key = nested_resources.empty? ? :id : :resource_id

  if (id = extract_id_from(controller_or_resource))
    options[id_key] = id
  end

  route_key = route_key_for(options[id_key], options)
  options[:model] = model_singular_route_key

  data = [:admin, self, route_key].compact + nested_resources

  polymorphic_path(data, options)
end