-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overriding rendering methods in devise_token_auth #597
Comments
at your 'user' model:
This will render your serializer.
that method is what you need to manage. |
Look at:
|
@omar28 Please close the issue if that worked for you. Otherwise, let me know so I can help you out ^_^ |
why you inheriting
to override SessionsController ? it should be |
Why I have this error:
|
@kjakub sorry! You are right. I didn't pay attention to that.
It works fine. I made the mistake @kjakub mentioned. Use
instead of
My bad! If that works, please close the issue @adisos |
I know, I solved by defining method |
Well, the "why this works like that", only the creators/maintainers know. I'm here because I use it and maybe I might be useful. |
Well, I found out. I'm using rubygems version, which doesn't have |
Me too! This is strange... any one? |
I think it's simple because gem author didn't update rubygems for a long time. |
Take a look to this ROUTES Controller overwrite
Credits to Doncote, here original post https://gitter.im/lynndylanhurley/devise_token_auth/archives/2015/12/18 |
I solved this by:
This is pretty easy. The documentation at https://github.com/lynndylanhurley/devise_token_auth#overriding-rendering-methods makes it sound WAY more confusing, it would be great to add a section describing this common and much simpler case (i.e. don't need custom JSON per controller method, just in general for devise-token-auth, but don't want to change it everywhere else in the app). |
@Meekohi your answer is working perfectly and solved it for me. |
I am currently building a rails api and I am using your devise_token_auth.
I’ve been stuck for a while on how to render custom data for user model. Rather than getting a ison like this:
{
"data": {
"id": 316,
"provider": "email",
"uid": "[email protected]",
"name": "olahlou",
"nickname": "olahlou",
"email": "[email protected]",
"score": 2,
"image": null
}
}
Let’s say the user has_many :posts, I would like to apply a user serializer(I am using active model serializers) to render something like (without the “data” key):
{
“id”:316,
“name”:”olahlou”,
“posts”:[{
#first post,
#second post...
}]
}
I’ve read the documentation an I guess I have to override the SessionController#render_create_success but I really don’t know how to do it.
Thank you in advance for your help.
The text was updated successfully, but these errors were encountered: