简体   繁体   English

条码未显示在轨道上[Barby Gem]

[英]Barcode not showing on rails [Barby Gem]

Gems used 使用的宝石

Ruby '1.9.3'

Rails '3.2.11'

Bbarby', '~> 0.5.1'

Chunky_png', '~> 1.3.0'

Application Helper 应用程序助手

require 'barby'
require 'barby/barcode/code_128'
require 'barby/barcode/ean_13'
require 'barby/outputter/png_outputter'
require 'barby/outputter/ascii_outputter'

require 'chunky_png'

Controller 调节器

barcode = Barby::Code128B.new('The noise of mankind has become too much')

File.open('code128b.png', 'w'){|f|
f.write barcode.to_png(:height => 20, :margin => 5)
}

View 视图

<%= image_tag("code128b.png") %>

The pages renders but not the barcode: 页面呈现但不呈现条形码:

在此处输入图片说明

File.open('code128b.png', 'w'){|f|
  f.write barcode.to_png(:height => 20, :margin => 5)
}

this is create file "code128b.png" in your root app path, and <%= image_tag("code128b.png") %> call image from assets / public 这是在您的根应用程序路径中创建文件“ code128b.png”,并且<%= image_tag("code128b.png") %>从资产/公共中调用图像

why you not upload your barcode into cloudinary and save it as url into your db :) 为什么不将条形码上载到cloudinary并将其另存为url到数据库中:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM