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

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

RoutingError (No route matches [OPTIONS]

App.config([
'$routeProvider'
'$httpProvider'
'$locationProvider'

($routeProvider, $httpProvider, $locationProvider, config) ->

$routeProvider

.when('/contents', {templateUrl: '/partials/contents.html'})
.when('/view1', {templateUrl: '/partials/partial1.html'})
.when('/view2', {templateUrl: '/partials/partial2.html'})

# Catch all
.otherwise({redirectTo: '/contents'})

delete $httpProvider.defaults.headers.common["X-Requested-With"]

# Without server side support html5 must be disabled.
$locationProvider.html5Mode(false)
])

Angular send POST request with resource service to Rails API

See how I solved it in this post.

Sending an Angular post request with parameter to Rails API

Regards,
Roberto.

ActionController::RoutingError (No route matches [GET] /assets/images

You can render the images which located at inner folder of assets/images by 2 ways.

1 Add following in application.rb

config.assets.paths << Rails.root.join('app', 'assets', 'hero-images')

Dir.glob("#{Rails.root}/app/assets/images/**/").each do |path|
config.assets.paths << path
end

Access the image directly

<img src="assets/hero-images/abyssal_underlord_sb.png">
<%= image_tag("abyssal_underlord_sb.png")%>

2. Simply add inner folder name above the file name.

<%= image_tag("hero-images/abyssal_underlord_sb.png")%> 

Refer to this link https://learn.co/lessons/images-and-the-asset-pipeline

ActionController::RoutingError (No route matches [GET] /javascripts/application.js)

This is old but for anyone coming across this issue, you need to change:
<%= javascript_include_tag 'application' %>
to
<%= javascript_pack_tag 'application' %>

rails no route matches after assets:precompile

In production mode, Rails will not be responsible for serving static assets. Therefore, you are getting this error. This is controlled by this setting in config/environment/production.rb in your application:

config.serve_static_assets = false

You can either set to that true or use a real server like Apache or Nginx which will serve the static assets. I suspect Pow may also do it.

Update

try this

  # Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = false


Related Topics



Leave a reply



Submit