All threads / Build REST API with Devise

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Build REST API with Devise

Oluwatosin Ekolie asked in Rails

Hi Guys, I've been struggling building an API for an iOS App to communicate with my Rails Web App. For authentication, I'm using Devise.

How do I create, update and delete a user through the API?

I have create the route:

namespace :api, defaults: {format: :json} do
namespace :v1 do
devise_scope :user do
post "/", :to => 'sessions#create'
delete "/logout", :to => 'session#destroy'
end
end
end

This is where I'm stuck

I think you can just simply make a POST to the same url as the sign up form normally which is /users. Same with PUT and DELETE but for logging in and out, you want to POST and DELETE to /sessions because that's a separate controller.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.