Comments (11)
Thanks for providing that project, @ivan-garanin
I dug into our source code via your project and it looks like neither this gem or active_model_serializers
have great support for non-ActiveRecord ORMs. Both gems key off of collection resources responding to a to_ary
method that ActiveRecord has implemented for collections, but Sequel does not.
That said, I implemented some basic support for sequel that you can try out.
#74
I tested this against your project:
gem 'grape-active_model_serializers',
github: 'ruby-grape/grape-active_model_serializers',
branch: 'support-sequel'
Let me know if it works for you!
from grape-active_model_serializers.
v1.5.1 has been released!
from grape-active_model_serializers.
Here is my base
grape file
module Nsi
class API < Grape::API
format :json
formatter :json, Grape::Formatter::ActiveModelSerializers
mount Nsi::DictionaryResource
mount Nsi::ParameterResource
mount Nsi::DictionaryParameterResource
add_swagger_documentation :format => :json,
:hide_documentation_path => true,
:mount_path => 'swagger_doc'
end
end
from grape-active_model_serializers.
same error without option
each_serialize: DictionarySerializer
from grape-active_model_serializers.
Looks like i have got anonymous class a = Class.new; a.name => nil
in Grape::ActiveModelSerializers::SerializerResolver
in instance initialization something like Grape::ActiveModelSerializers::SerializerResolver.new(Class.new, opts)
hm... I already have got it there...
module Grape
module Formatter
module ActiveModelSerializers
class << self
def call(resource, env)
# !!!! resource.class.name => nil, resource.class => #<Class:0x005...>
options = build_options(resource, env)
serializer = fetch_serializer(resource, options)
if serializer
::ActiveModelSerializers::Adapter.create(
serializer, options
).to_json
else
Grape::Formatter::Json.call(resource, env)
end
end
def build_options(resource, env)
Grape::ActiveModelSerializers::OptionsBuilder.new(
resource, env
).options
end
def fetch_serializer(resource, options)
Grape::ActiveModelSerializers::SerializerResolver.new(
resource, options
).serializer
end
end
end
end
end
hm... I need help guys :(' What I'm doing wrong?
from grape-active_model_serializers.
Hi @ivan-garanin, is there a project that I would be able to reproduce this error in? If I can replicate the error, I can look into patching it
from grape-active_model_serializers.
Hi @drn , I'll publish on github my cutted project for you tomorrow.
from grape-active_model_serializers.
@drn, I made example app(with all same configs/settings and so on) https://github.com/ivan-garanin/example-for-grape_active_model_serializer check readme to launch it faster
from grape-active_model_serializers.
@drn thank you!
from grape-active_model_serializers.
👍 worked? ill get that merged in over the next few days and release a new gem version
from grape-active_model_serializers.
yea, everything is OK, ty for help, ping me when release ll be ready and I'd remove that ugly line from Gemfile)
from grape-active_model_serializers.
Related Issues (20)
- not working on custom json response HOT 2
- API Versioning: Supporting Active Model Serializers namespacing HOT 4
- Changing adapter in AMS is not affected to output HOT 9
- Issues versioning serializers with Grape 1.4 master HOT 17
- Swagger documentation HOT 3
- Globally specify serialization adapter HOT 1
- Release v. next HOT 5
- Convert all AM keys from snake_case to camelCase HOT 3
- `include: '**'` option not working on serailizers HOT 8
- [grape 1.0.0] Json root does not exist in response.
- Custom formatted error messages HOT 1
- default_serializer_options no longer works HOT 1
- Array root documentation HOT 3
- Namespaces with associations HOT 2
- Documentation on the ErrorSerializer HOT 3
- Release v. Next
- How can I have a resource loaded in included (jsonapi format) ?
- Test failures about Hash#deep_dup missing HOT 2
- Custom Metadata not woking
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grape-active_model_serializers.