JSONAPI stuff
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#ActiveModel::Serializer.setup do |config|
|
||||
# config.embed = :ids
|
||||
# config.embed_in_root = true
|
||||
# config.adapter = :json_api
|
||||
#end
|
||||
module ActiveModel::SerializerSupport
|
||||
def read_attribute_for_serialization(attr)
|
||||
public_send attr
|
||||
end
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
config.embed = :ids
|
||||
config.embed_in_root = true
|
||||
#config.adapter = :json_api
|
||||
end
|
||||
#module ActiveModel::SerializerSupport
|
||||
# def read_attribute_for_serialization(attr)
|
||||
# public_send attr
|
||||
# end
|
||||
#end
|
||||
|
||||
=begin
|
||||
class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
|
||||
def add_resource_relationships_old1(attrs, serializer, options = {})
|
||||
options[:add_included] = options.fetch(:add_included, true)
|
||||
@@ -16,7 +17,6 @@ class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
|
||||
name = association.key
|
||||
association_options = association.options
|
||||
next unless object = serializer.object
|
||||
=begin
|
||||
if association_options[:type] == :has_many
|
||||
# todo check for object["#{name}_ids"]
|
||||
association_value = association_options[:association_options][:url] ? [] : serializer.send(name)
|
||||
@@ -45,7 +45,6 @@ class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
|
||||
elsif !association_value.nil? && !association_value.instance_of?(Object)
|
||||
association_options[:association_options][:virtual_value] = association_value
|
||||
end
|
||||
=end
|
||||
association_serializer = association.serializer
|
||||
opts = association_options[:association_options]
|
||||
opts = association.options
|
||||
@@ -81,5 +80,7 @@ class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
|
||||
resource[:relationships][name][:links][:related] = related_url
|
||||
end
|
||||
end
|
||||
=end
|
||||
#ActiveModel::Serializer.config.adapter = :json_api
|
||||
ActiveModel::Serializer.config.adapter = Qwaiter::JsonAdapter
|
||||
#ActiveModel::Serializer.config.adapter = Qwaiter::JsonAdapter
|
||||
#ActiveModel::Serializer.config.adapter = :flatten_json
|
||||
|
||||
Reference in New Issue
Block a user