Ruby on Rails资产管道(未找到文件)

时间:2017-04-06 21:05:33

标签: ruby-on-rails asset-pipeline

我在使用rails 5.0.2和资产管道方面遇到了麻烦。我只是尝试将文件放在vendor文件夹中,然后在Application.js和.css文件中引用它们。

我一直收到以下错误 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

如上所示,{< {1}}文件路径列在"已签入"上面的路径列表(列表底部)。

完整的文件路径为/Users/user/Ruby/app_name/vendor/pages

不确定我是否遗漏了明显的东西?我已经尝试在application.rb文件中注册资产,我还尝试将它们移到app / assets /目录中,但没有运气。

1 个答案:

答案 0 :(得分:1)

供应商资产应放在/vendor/assets/javascripts/vendor/assets/stylesheets中 - 将这些非常通用的资产放在/pages/pages-plugins/中似乎过于复杂和愚蠢。

但是bootstrapfont-awesome和许多流行的lib都有“gemified”版本。使用它们通常比在存储库中包含供应商代码更可取,因为更新依赖项会在版本历史记录中产生大量噪音和流失。

另一个巨大的优点是“宝石版本”在开发中使用未经明确的资产形式,使调试变得更加简单。