[英]File to import not found or unreadable when using Rails asset gem
I'm trying to create a rails asset gem whose source is here . 我正在尝试创建一个来源在这里的rails资产gem。 The problem is that when I use the gem in try to require or import the asset files in my Rails 4 project, I get the error:
问题是,当我使用gem尝试在Rails 4项目中要求或导入资产文件时,出现错误:
File to import not found or unreadable: jquery.xdan.datetimepicker
I've inspected the paths it is looking through, and it looks like it's not actually looking in the assets directory for my gem (the gem folder isn't anywhere in the list). 我已经检查了它正在查找的路径,并且看起来它实际上并没有在我的gem的资产目录中查找(gem文件夹不在列表中的任何位置)。 So, it seems like the gem isn't getting required, since if it was, the
Engine
would be getting loaded, indicating to Rails that I have an assets folder somewhere. 因此,似乎不需要使用gem,因为如果需要,则将加载
Engine
,并向Rails指示我在某处有一个资产文件夹。 Can anyone see what I'm missing? 谁能看到我所缺少的吗? From what I can tell, I'm doing everything that other asset gems are doing.
据我所知,我正在做其他资产瑰宝所做的一切。
I looked at your Gem. 我看着你的宝石。 In order to get it working, rename lib/xdan_datetimepicker_rails.rb to lib/xdan-datetimepicker-rails.rb .
为了使其正常运行,将lib / xdan_datetimepicker_rails.rb重命名为lib / xdan-datetimepicker-rails.rb 。
In your Rails project, uninstall your old gem and install the new one. 在Rails项目中,卸载旧的gem并安装新的gem。 To make sure it's installed properly:
为了确保正确安装:
$ rails c
> pp MyRailsApp::Application.assets.paths
You should see an array of paths that are in the asset pipeline. 您应该看到资产管道中的一系列路径。 Look for:
寻找:
/gem/path/to/xdan-datetimepicker-rails-0.0.1/app/assets/javascripts
/gem/path/to/xdan-datetimepicker-rails-0.0.1/app/assets/stylesheets
NOTE: Restart rails c
and/or rails s
if you're not seeing it. 注意:如果看不到,请重新启动
rails c
和/或rails s
。
Finally, in order to use the assets: 最后,为了使用资产:
app/assets/javascript/application.js 应用程序/资产/ JavaScript的/ application.js中
//= require jquery.xdan.datetimepicker
app/assets/stylesheets/stylesheet.css.scss 应用程序/资产/样式表/ stylesheet.css.scss
*= require jquery.xdan.datetimepicker
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.