简体   繁体   中英

Devise + Rails-API

So, I'm starting an API from a new rails-api project. I would like to use Devise for all the authentication stuff. I already learned a lot from my recent googling-sessions. I have a working SessionsController, however I noticed with the RegisterController that I certainly missed something about the duo Rails-API+Devise.

I still get the following error :

NameError (undefined local variable or method 'flash' for #    <RegistrationsController:0x007ff6022b44b8>)`

From a pure API perspective should I keep working with Devise flash messages since I don't want to render views? I didn't included ActionDispatch::Flash based on the principe that I'll just render JSON. So, is there a way to properly deal with that case?

Thank you.

I would rather suggest to send messages in json instead of having flash[:messages]. If you are not dealing with views then go for json, flash is not required.

Something like:

      render :json => {:message => "message", :data => data}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM