4

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.

1

1 Answer 1

3

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.