Getting Controller specific CSS and JavaScript Assets
You can run into problems of assets inclusion for specific controllers after generating scaffolding or generating controllers in Rails. This is the default behavior of Rails 4 and below. You can eliminate this problem by modifying several files with the following lines of code.
Adding the following line to assets.rb
> Rails.application.config.assets.precompile += [/.*\.png/,/.*\.ico/,/.*\.jpg/,/.*\.js/,/.*\.css/]
You need to remove directory inclusion two files in the assets folder
> //= require_tree .
1. Application.css.scss
2. Application.js
You need to add the following line to application.rb
> config.assets.initialize_on_precompile = false