When using assets stylesheet to load a CSS file, I noticed that it only loads on the index page. Upon inspecting with F12, the console shows the URL for other pages as well, which appends "/cloths" to the asset path. I am currently utilizing the default layout of application.html.erb.
Here is my route.rb:
Rails.application.routes.draw do
resources :categories
resources :cloths
end
My cloths_controller.rb looks like this:
class ClothsController < ApplicationController
before_action :set_cloth, only: [:show, :edit, :update, :destroy]
... (controller actions continue here) ...
</div>
And in my application.html.erb file, where the issue seems to lie with asset URLs:
<!DOCTYPE HTML>
<html>
<head>
<title>Batik</title>
... (more HTML markup and script tags) ...
$(document).ready(function() {
$('.popup-with-zoom-anim').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,
removalDelay: 300,
mainClass: 'my-mfp-zoom-in'
});
});
</script>
</head>
<body>
... (further HTML content) ...
</body>
</html>
Although everything works fine on the Index page, the asset URLs become different on other pages such as show, edit, and add. The console shows URLs like:
GET http://localhost:3000/cloths/assets/bootstrap.css (404 not found)
This leads me to wonder why the URL path suddenly changes to include "/cloths" instead of just remaining as "/assets".