简体   繁体   中英

how to export assets from ruby gem to rails

I am building a gem (see here for full source code) and I am having issues exporting assets to Rails.

The tests I wrote in the gem work well, but when I install the gem on Rails some of the assets are missing, for example the images are not found, I got the following error on Rails:

# error I got when installed on Rails
unable to open image `app/assets/images/swiss_cross.png': No such file or directory @ error/blob.c/OpenBlob/2701

The Gem code raising the error is this one:

# Gem source code
# lib/qr-bills/qr-generator.rb
[...]
    swiss_cross = Image.read("app/assets/images/swiss_cross.png")[0]
[...]

Any ideas what I am missing?

Simply use full paths to your assets like it has been done here and don't depend on the files being present on your current directory. In your case Rails' already has app/* .

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