Risposte:
In Rails 4:
skip_before_action :verify_authenticity_token, except: [:create, :update, :destroy]
E Rotaie 3:
skip_before_filter :verify_authenticity_token
Per le versioni precedenti:
Per le singole azioni, puoi fare:
protect_from_forgery :only => [:update, :destroy, :create]
#or
protect_from_forgery :except => [:update, :destroy, :create]
Per un intero controller, puoi fare:
skip_before_action :verify_authenticity_token
skip_forgery_protection
. Vedi i documenti API .
In Rails4 usi skip_before_action
con except
o only
.
class UsersController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:create]
skip_before_action :some_custom_action, except: [:new]
def new
# code
end
def create
# code
end
protected
def some_custom_action
# code
end
end