Getting ActionController::RoutingError (No route matches [OPTIONS] "/users" when trying to POST data to RAils server with AngularJS Getting ActionController::RoutingError (No route matches [OPTIONS] "/users" when trying to POST data to RAils server with AngularJS angularjs angularjs

Getting ActionController::RoutingError (No route matches [OPTIONS] "/users" when trying to POST data to RAils server with AngularJS


Rails cannot process [OPTIONS] requests

You have to install rack-cors to process CORS.

Here's where your problem comes from:

  resources :users do    collection { post :create_user , via: :options  }    # via: :options ?  end


This issue was posted long ago, but I had this issue...

I used gem'rack-cors', but in my case I dealt with this with a different setting.

config/application.rb

  class Application < Rails::Application    config.middleware.use Rack::Cors do      allow do        origins '*'        resource '*',                 headers: :any,                 expose: %w(access-token expiry token-type uid client),                 methods: %i(post)      end    end  end