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
Finding the Date for a Given Week Number
How to Define a Simple Global Variable in an Rspec Test That Can Be Accesed by Helper Functions
Convert Ip Address to 32 Bit Integer in Ruby
Ruby's Argv Can Be Empty on Windows Depending on a Way to Run Script
What Regex How to Use to Get the Domain Name from a Url in Ruby
"Dyld: Library Not Loaded", "Libruby.1.9.1.Dylib" When Calling "Mvim ." in the Command Line
Ruby on Rails. Bundler. Cucumber. Rake Aborted! Command Failed with Status (1)
Can You 'Require' Ruby File in Irb Session, Automatically, on Every Command
Can't Run Ruby 2.2.3 with Rvm on Osx
Detecting Regional Settings (List Separator) from Web
Undefined Method 'Require_Relative' for Main:Object (Nomethoderror)
Ruby, How to Access Local Variables Outside the Do - End Loop
Why Are My Rspec Tests Failing, But My App Is Working
Why Does Ruby Release Memory Only Sometimes