Comments (17)
Hey @nhinze, I did some work on namespacing against ASM v0.10.0+ in this pull. The changes in the pull should address your issue.
Grape-ASM tries to send a namespace key to ActiveModel::Serializer.serializer_for
here, but support for that key is no longer supported by ASM as described here. So, grape-ASM has to handle serializer lookup by version explicitly.
from grape-active_model_serializers.
@drn, thanks. I'll wait until its merged into master to try it out.
In my signup.rb above, I use "resource", how do I namespace it? Just namespace right around the "get"? I was trying to get it to work with ams .9.5, but it's giving me the same error.
from grape-active_model_serializers.
Namespacing is based off of the version
option, which is v1
in your example in signup.rb. Looking at it, it looks like the surrounding Mobile
module might cause issues as namespacing is being based off the version option exclusively. However, constant resolution might handle it fine if you don't have another top-level namespace with another V1::SignupsSerializer somewhere in it.
I'll get that v0.10 support pull merged onto master today. If it doesn't solve your issue, let me know and we'll work on adding some specs and a fix for your use case.
from grape-active_model_serializers.
@nhinze can you try your project against master?
from grape-active_model_serializers.
Using grape-active_model_serializers 1.4.0 from https://github.com/ruby-grape/grape-active_model_serializers.git (at master@a48d57c)
I still get this error:
from grape-active_model_serializers.
The API structure above is inspired from http://codetunes.com/2014/introduction-to-building-apis-with-grape/ . I also named my first API "Mobile", because this one will interact with my mobile app. There will be a separate API for another backend.
This is my first time building an API and maybe my setup is not quite correct. I'll gladly take any recommendations.
from grape-active_model_serializers.
@nhinze would you be able to give me access to the project you're experiencing this error with? If so, I can dig into the error. If not, would you be able to write a spec that covers this issue?
Re: the Mobile
name, if there won't be another api in the rails application, you can get rid of the mobile
namespace. the folders within the api namespace should be used for versioning as described in the README where an file hierarchy is displayed.
from grape-active_model_serializers.
The "mobile" api used to be called " api" and the folder structure was /app/api/api/v1 . I plan to have a second API for another service. The api would not work in /app/api/v1.
I have the project on GitLab. I'll PM you.
from grape-active_model_serializers.
@nhinze - you can try #58 out. I tested it against your project. Thanks for giving me access to it.
from grape-active_model_serializers.
@drn this works well. Thank You!
from grape-active_model_serializers.
Great! I'll let you know when a fix is merged after I get back from vacation on Thursday. I'll close this issue then
from grape-active_model_serializers.
@nhinze #60 has been merged which includes a fix for your issue, so you can point your project to master until v1.5.0 is released
from grape-active_model_serializers.
@drn tried to use the master branch, but it doesn't work. I get the same error as before. The namespace-inferred-serializer branch works fine.
from grape-active_model_serializers.
Hey @nhinze - I forgot to include handling for collections in that last pull. #61 should fix it after it's merged in. I'll let you know as soon as that's merged in and will do a v1.5.0 after you confirm it's working
from grape-active_model_serializers.
Okay @nhinze - #61 is merged. I tested it successfully against your project. Note that you'll need to add the Mobile::
namespace to V2::SignupSerializer
-> Mobile::V2::SignupSerializer
for it to work.
from grape-active_model_serializers.
Thanks. It works now.
from grape-active_model_serializers.
Perfect, thanks for following up
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
- 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
- undefined method `deconstantize' for nil:NilClass HOT 11
- [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.