I want to make a POST request for my local developer, for example:
HTTParty.post('http://localhost:3000/fetch_heroku', :body => {:type => 'product'},)
However, from the server console, it reports
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
Here is my controller and setting up routes, it's pretty simple.
def fetch_heroku if params[:type] == 'product' flash[:alert] = 'Fetch Product From Heroku' Heroku.get_product end end post 'fetch_heroku' => 'admin#fetch_heroku'
I'm not sure what I need to do? Disabling CSRF will certainly work, but I think it should be my mistake when creating such an API.
Is there any other setup I need to do?
ruby-on-rails
cqcn1991 03 Feb '16 at 15:40 2016-02-03 15:40
source share