samedi 15 avril 2017

ActionController::InvalidAuthenticityToken in DonationsController#create_user_account

I am new in ruby on rails and I am trying to send the post request using ajax to the controller method but the it throw the exception

ActionController::InvalidAuthenticityToken in DonationsController#create_user_account

I have google it but no idea what to do to solve this.

It is the main controller

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

Here is the code of donations controller

def create_user_account
    @donation = Donation.find(params[:a])
    @pars = [@donation.a]
    print @pars
    render plain: "OK"
  end

private # Use callbacks to share common setup or constraints between actions. def set_donation @donation = Donation.find(params[:id]) end

def set_campaign
  @campaign = Campaign.find(params[:campaign_id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def donation_params
  params.require(:donation).permit(:amount, :user_id, :campaign_id)
end

Aucun commentaire:

Enregistrer un commentaire