JSONApi progress

This commit is contained in:
2015-09-03 20:42:48 +02:00
parent f47a8a9ed0
commit e4dde28dd0
27 changed files with 215 additions and 64 deletions
@@ -10,10 +10,13 @@ module ActiveModel::SerializerSupport
end
class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
def add_resource_relationships(attrs, serializer, options = {})
def add_resource_relationships_old1(attrs, serializer, options = {})
options[:add_included] = options.fetch(:add_included, true)
serializer.class._associations.dup.each do |name, association_options| #do |name, association, opts|
serializer.associations.each do |association| #do |name, association, opts|
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)
@@ -42,8 +45,12 @@ 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
attrs[:relationships] ||= {}
binding.pry
if association_serializer.respond_to?(:each)
if opts[:url]
+8 -1
View File
@@ -83,10 +83,17 @@ Qwaiter::Application.routes.draw do
get :current
end
resources :orders, only: [:index]
member do
get :table
end
end
resources :orders, only: [:create]
resources :tables, only: [:show]
resources :tables, only: [:show] do
member do
get :supplier
end
end
end