如何创建员工ID卡的条形码

时间:2016-04-20 08:39:12

标签: ruby-on-rails ruby

gemfile由gem 'barby'

组成

我在控制器中编写了一个代码:

require 'barby'    
require 'barby/barcode/ean_13'    
require 'barby/outputter/ascii_outputter'    
require 'barby/outputter/html_outputter'

def show
  @card = Barby::EAN13.new(emp_code)
  @card_for_html = Barby::HtmlOutputter.new(@card)
end

private
  def emp_code
    @emp_code = "#{@user.date_of_joining} + #{@user.full_name} + #{@user.id}"
  end

在我看来,我写道:

<%@card.ascii=@card.to_ascii%> </p>    
<%=raw @card_path_for_html.to_html%>   </p>

产生错误undefined method 'to_ascii'

任何人都可以帮助我吗?

0 个答案:

没有答案