mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Provide Rails url_helpers via SerializationContext
This commit is contained in:
@@ -20,9 +20,11 @@ module ActiveModel
|
||||
|
||||
# Define a link on a serializer.
|
||||
# @example
|
||||
# link :self { "//example.com/posts/#{object.id}" }
|
||||
# link(:self) { resource_url(object) }
|
||||
# @example
|
||||
# link :self, "//example.com/user"
|
||||
# link(:self) { "http://example.com/resource/#{object.id}" }
|
||||
# @example
|
||||
# link :resource, "http://example.com/resource"
|
||||
#
|
||||
def link(name, value = nil, &block)
|
||||
_links[name] = block || value
|
||||
|
||||
Reference in New Issue
Block a user