简体   繁体   中英

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 . 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:

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). 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. 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 .

In your Rails project, uninstall your old gem and install the new one. 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.

Finally, in order to use the assets:

app/assets/javascript/application.js

//= require jquery.xdan.datetimepicker

app/assets/stylesheets/stylesheet.css.scss

 *= require jquery.xdan.datetimepicker

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