简体   繁体   中英

Ruby on Rails Asset Pipeline (files not found)

I'm having troubles with rails 5.0.2 and asset-pipeline. I'm simply trying to put the files in the vendor folder and then reference them in the Application.js and .css files.

I keep getting the following error Sprockets::FileNotFound

Showing /Users/user/Ruby/app_name/app/views/layouts/application.html.erb where   line #16 raised:

couldn't find file 'pages-plugins/bootsrapv3/css/bootstrap.min' with type 'text/css'
Checked in these paths: 
/Users/user/Ruby/app_name/app/assets/config
/Users/user/Ruby/app_name/app/assets/images
/Users/user/Ruby/app_name/app/assets/javascripts
/Users/user/Ruby/app_name/app/assets/stylesheets
/Users/user/Ruby/app_name/vendor/assets/javascripts
/Users/user/Ruby/app_name/vendor/assets/stylesheets
/Users/user/.rvm/gems/ruby-2.3.1/gems/jquery-rails-4.3.1/vendor/assets/javascripts
/Users/user/.rvm/gems/ruby-2.3.1/gems/coffee-rails-4.2.1/lib/assets/javascripts
/Users/user/.rvm/gems/ruby-2.3.1/gems/actioncable-5.0.2/lib/assets/compiled
/Users/user/.rvm/gems/ruby-2.3.1/gems/turbolinks-source-5.0.0/lib/assets/javascripts
/Users/user/Ruby/app-name/vendor/pages
Extracted source (around line #15):

* BEGIN VENDOR CSS FOR PAGES
*= require pages-plugins/pace/pace-theme-flash
*= require pages-plugins/bootsrapv3/css/bootstrap.min
*= require pages-plugins/font-awesome/css/font-awesome
*= require pages-plugins/jquery-scrollbar/jquery.scrollbar
*= require pages-plugins/bootstrap-select2/select2

As you can see above the /Users/user/Ruby/app_name/vendor/pages file path is listed in the "checked in" paths list above (bottom of list).

The complete file path is /Users/user/Ruby/app_name/vendor/pages/pages-plugins/

Not sure if i'm missing something obvious? I've tried to register the assets in application.rb file, I've also tried to move them inside the app/assets/ directory with no luck.

Vendor assets should be placed in /vendor/assets/javascripts and /vendor/assets/stylesheets - placing those very generic assets in /pages/pages-plugins/ seems overcomplicated and silly.

But there are "gemified" versions of bootstrap , font-awesome and many popular libs. Using them is generally preferable to including vendor code in your repository as updating dependencies otherwise create tons of noise and churn in the version history.

Another huge plus is that the "gem versions" use an unminified form of the asset in development with makes debugging far simpler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM