简体   繁体   English

使用Rails资产gem时找不到导入文件或不可读

[英]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.

相关问题 Sass :: SyntaxError:在Rails 3中找不到要导入的文件或不可读的文件 - Sass::SyntaxError: File to import not found or unreadable In Rails 3 Rails + Twitter Bootstrap:导入未找到或不可读的文件:twitter / bootstrap - Rails + Twitter Bootstrap: File to import not found or unreadable: twitter/bootstrap 错误:要导入的文件未找到或不可读:指南针。 在轨道3.1 - Error: File to import not found or unreadable: compass. in rails 3.1 找不到断点(gem)或不可读 - breakpoint (gem) not found or unreadable 找不到导入文件或文件不可读:引导程序错误行#5 - File to import not found or unreadable: bootstrap error line #5 找不到导入的Sass文件或文件不可读,文件确实存在 - Sass file to import not found or unreadable, file does exist Sass::SyntaxError:未找到要导入的文件或无法读取:生产中的指南针 - Sass::SyntaxError: File to import not found or unreadable: compass in production 找不到导入文件或无法读取文件:指南针手表无法运行 - File to import not found or unreadable: compass watch cant run 语法错误:找不到导入文件或不可读:指南针/ css3 - Syntax error: File to import not found or unreadable: compass/css3 未找到Susy2文件或无法读取的Susy2文件,通过Gulp与Compass一起编译 - Susy2 File to Import not found or unreadable, compiling with Compass via Gulp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM