Voglio fare POST requestal mio sviluppatore locale, in questo modo:
HTTParty.post('http://localhost:3000/fetch_heroku',
:body => {:type => 'product'},)
Tuttavia, dalla console del server segnala
Started POST "/fetch_heroku" for 127.0.0.1 at 2016-02-03 23:33:39 +0800
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by AdminController#fetch_heroku as */*
Parameters: {"type"=>"product"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 1ms
Ecco il mio controller e la configurazione delle rotte, è abbastanza semplice.
def fetch_heroku
if params[:type] == 'product'
flash[:alert] = 'Fetch Product From Heroku'
Heroku.get_product
end
end
post 'fetch_heroku' => 'admin#fetch_heroku'
Non sono sicuro di cosa devo fare? Disattivare il CSRF funzionerebbe sicuramente, ma penso che dovrebbe essere un mio errore durante la creazione di tale API.
C'è qualche altra configurazione che devo fare?
protect_from_forgery with: :null_session.