Rails5 API with Devise gem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rails5 API with Devise gem

Learn Rails
Hi all,

I am using devise gem in my rails5 api. There is a endpoint for login am using my own endpoint for login and when I try to login it works fine but devise related column are not updating like sign_in_count and ip related. can some on help me how can I do those things and any guide to create api with rails5..



Thanks in advance..

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Rails5 API with Devise gem

Walter Lee Davis

> On Oct 23, 2017, at 7:57 AM, Learn Rails <[hidden email]> wrote:
>
> Hi all,
>
> I am using devise gem in my rails5 api. There is a endpoint for login am using my own endpoint for login and when I try to login it works fine but devise related column are not updating like sign_in_count and ip related. can some on help me how can I do those things and any guide to create api with rails5..
>
>

What do you see in your rails log when you log in? Are any errors shown in the log? When you say "it works fine", what does that mean? Do you have

before_action :authenticate_user!

on one of the controllers you are able to navigate to after you log in? If not, the fact that you can get to one of the routes in that controller means nothing vis-a-vis Devise.

What do you see on a view where you have added this line of ERB:

<%= debug current_user %>

As to the API, the Rails Guide is a pretty good place to start: http://guides.rubyonrails.org/api_app.html

Walter

>
> Thanks in advance..
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/78DD15C8-4AC3-4BC3-851B-8DEEDE095CC0%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Rails5 API with Devise gem

Learn Rails
As this is api we don't have views. <%= debug current_user %> can't be done. I have just used devise gem am trying to override the login of devise as devise have its own login process but in api it does not work that way.. Correct me am wrong..

On Tuesday, October 24, 2017 at 6:44:23 AM UTC+5:30, Walter Lee Davis wrote:

> On Oct 23, 2017, at 7:57 AM, Learn Rails <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="pSIyYwZBBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">learnrai...@...> wrote:
>
> Hi all,
>
> I am using devise gem in my rails5 api. There is a endpoint for login am using my own endpoint for login and when I try to login it works fine but devise related column are not updating like sign_in_count and ip related. can some on help me how can I do those things and any guide to create api with rails5..
>
>

What do you see in your rails log when you log in? Are any errors shown in the log? When you say "it works fine", what does that mean? Do you have

before_action :authenticate_user!

on one of the controllers you are able to navigate to after you log in? If not, the fact that you can get to one of the routes in that controller means nothing vis-a-vis Devise.

What do you see on a view where you have added this line of ERB:

<%= debug current_user %>

As to the API, the Rails Guide is a pretty good place to start: <a href="http://guides.rubyonrails.org/api_app.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fguides.rubyonrails.org%2Fapi_app.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFgYNcjbvE9bIwBK4vbklixzmJhIg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fguides.rubyonrails.org%2Fapi_app.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFgYNcjbvE9bIwBK4vbklixzmJhIg&#39;;return true;">http://guides.rubyonrails.org/api_app.html

Walter

>
> Thanks in advance..
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="pSIyYwZBBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="pSIyYwZBBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5f91bf19-c1cf-49f4-b2ed-d1a1e2f32cd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Rails5 API with Devise gem

Walter Lee Davis

> On Oct 24, 2017, at 2:08 AM, James <[hidden email]> wrote:
>
> As this is api we don't have views. <%= debug current_user %> can't be done. I have just used devise gem am trying to override the login of devise as devise have its own login process but in api it does not work that way.. Correct me am wrong..

I see, didn't get that. I did a quick google, and found this, which may apply in your case then. If you're not using token_authenticatable in your model, then you should add it. http://jessewolgamott.com/blog/2012/01/19/the-one-with-a-json-api-login-using-devise/

Walter

>
> On Tuesday, October 24, 2017 at 6:44:23 AM UTC+5:30, Walter Lee Davis wrote:
>
> > On Oct 23, 2017, at 7:57 AM, Learn Rails <[hidden email]> wrote:
> >
> > Hi all,
> >
> > I am using devise gem in my rails5 api. There is a endpoint for login am using my own endpoint for login and when I try to login it works fine but devise related column are not updating like sign_in_count and ip related. can some on help me how can I do those things and any guide to create api with rails5..
> >
> >
>
> What do you see in your rails log when you log in? Are any errors shown in the log? When you say "it works fine", what does that mean? Do you have
>
> before_action :authenticate_user!
>
> on one of the controllers you are able to navigate to after you log in? If not, the fact that you can get to one of the routes in that controller means nothing vis-a-vis Devise.
>
> What do you see on a view where you have added this line of ERB:
>
> <%= debug current_user %>
>
> As to the API, the Rails Guide is a pretty good place to start: http://guides.rubyonrails.org/api_app.html 
>
> Walter
>
> >
> > Thanks in advance..
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> > To post to this group, send email to [hidden email].
> > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5f91bf19-c1cf-49f4-b2ed-d1a1e2f32cd1%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/69F80192-5381-4BDD-A3D9-E959FE6707D7%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Rails5 API with Devise gem

Walter Lee Davis
In reply to this post by Learn Rails
Sorry, check the sell-by date on that last one. Look here: https://github.com/plataformatec/devise/wiki/How-To:-Simple-Token-Authentication-Example

Token was taken out of Devise proper, but it still lives in third-party gems.

Walter

> On Oct 24, 2017, at 2:08 AM, James <[hidden email]> wrote:
>
> As this is api we don't have views. <%= debug current_user %> can't be done. I have just used devise gem am trying to override the login of devise as devise have its own login process but in api it does not work that way.. Correct me am wrong..
>
> On Tuesday, October 24, 2017 at 6:44:23 AM UTC+5:30, Walter Lee Davis wrote:
>
> > On Oct 23, 2017, at 7:57 AM, Learn Rails <[hidden email]> wrote:
> >
> > Hi all,
> >
> > I am using devise gem in my rails5 api. There is a endpoint for login am using my own endpoint for login and when I try to login it works fine but devise related column are not updating like sign_in_count and ip related. can some on help me how can I do those things and any guide to create api with rails5..
> >
> >
>
> What do you see in your rails log when you log in? Are any errors shown in the log? When you say "it works fine", what does that mean? Do you have
>
> before_action :authenticate_user!
>
> on one of the controllers you are able to navigate to after you log in? If not, the fact that you can get to one of the routes in that controller means nothing vis-a-vis Devise.
>
> What do you see on a view where you have added this line of ERB:
>
> <%= debug current_user %>
>
> As to the API, the Rails Guide is a pretty good place to start: http://guides.rubyonrails.org/api_app.html 
>
> Walter
>
> >
> > Thanks in advance..
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> > To post to this group, send email to [hidden email].
> > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/afaa1ac6-4999-436e-bf2e-7ff02ec0663b%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5f91bf19-c1cf-49f4-b2ed-d1a1e2f32cd1%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/54C29950-ACD3-4F7E-8621-452A8F5257A5%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Rails5 API with Devise gem

David Gleba
I created a little app builder so I can study features and rebuild them many times to learn. Running it creates an app with jwt token auth and views too.



This was generated by bashrail - https://github.com/dgleba/brail347a22

Maybe it could help you.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/acd41548-b79b-4b92-a4d5-17dcfd7f3437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.