Chcę napisać POST requestdo mojego lokalnego dewelopera w następujący sposób:
HTTParty.post('http://localhost:3000/fetch_heroku',
:body => {:type => 'product'},)
Jednak z konsoli serwera to raportuje
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
Oto konfiguracja mojego kontrolera i tras, jest to dość proste.
def fetch_heroku
if params[:type] == 'product'
flash[:alert] = 'Fetch Product From Heroku'
Heroku.get_product
end
end
post 'fetch_heroku' => 'admin#fetch_heroku'
Nie jestem pewien, co muszę zrobić? Wyłączenie CSRF na pewno by się udało, ale myślę, że to powinien być mój błąd podczas tworzenia takiego API.
Czy muszę wykonać jakąś inną konfigurację?
protect_from_forgery with: :null_session.