lib/jsonapi/routing_ext.rb in jsonapi-resources-0.10.0.beta5 vs lib/jsonapi/routing_ext.rb in jsonapi-resources-0.10.0.beta6
- old
+ new
@@ -18,10 +18,12 @@
def jsonapi_resource(*resources, &_block)
@resource_type = resources.first
res = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(@resource_type))
+ res._routed = true
+
unless res.singleton?
warn "Singleton routes created for non singleton resource #{res}. Links may not be generated correctly."
end
options = resources.extract_options!.dup
@@ -82,10 +84,12 @@
def jsonapi_resources(*resources, &_block)
@resource_type = resources.first
res = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(@resource_type))
+ res._routed = true
+
if res.singleton?
warn "Singleton resource #{res} should use `jsonapi_resource` instead."
end
options = resources.extract_options!.dup
@@ -218,10 +222,12 @@
options = relationship.extract_options!.dup
relationship_name = relationship.first
relationship = source._relationships[relationship_name]
+ relationship._routed = true
+
formatted_relationship_name = format_route(relationship.name)
if relationship.polymorphic?
options[:controller] ||= relationship.class_name.underscore.pluralize
else
@@ -239,9 +245,11 @@
source = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix)
options = relationship.extract_options!.dup
relationship_name = relationship.first
relationship = source._relationships[relationship_name]
+
+ relationship._routed = true
formatted_relationship_name = format_route(relationship.name)
related_resource = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(relationship.class_name.underscore))
options[:controller] ||= related_resource._type.to_s