This tutorial from Fancy Pixel says:
Now we need to change the application controller so that it inherits from ActionController::API, and kiss the protect_from_forgery goodbye. Since we are serving only JSON, it makes sense to add
respond_to :jsonto the applciation controller, helps DRYing all out. While we are at it, we might as well delete the assets and views folders, we won’t need them.
I am not sure about what I am supposed to do.
This is what my application controller looks like:
class ApplicationController < ActionController::API
respond_to :json
end
Is it correct?
Also, should I keep or remove protect_from_forgery with: :null_session :
class ApplicationController < ActionController::API
protect_from_forgery with: :null_session
respond_to :json
end
Aucun commentaire:
Enregistrer un commentaire