【发布时间】:2017-10-18 19:03:17
【问题描述】:
我正在使用这个 gem 来帮助我制作固定的文件格式化程序。我正在关注文档但收到错误
require('fixy')
class Record < Fixy::Record
include Fixy::Formatter::Alphanumeric
# Define record length
set_record_length 20
# Fields Declaration:
# -----------------------------------------------------------
# name size Range Format
# ------------------------------------------------------------
field :first_name, 10, '1-10' , :alphanumeric
field :last_name , 10, '11-20', :alphanumeric
# Any required data for the record can be
# provided through the initializer
def initialize(first_name, last_name)
@first_name = first_name
@last_name = last_name
end
# 2) Using a method definition.
# This is most interesting when complex logic is involved.
def last_name
@last_name
end
end
shinken = Reky.new('Sarah', 'Smith')
p shinken.generate
最后一个方法:shinken.generate 给出错误:generate': undefined methodfirst_name' for # (NoMethodError)
这可能是什么原因造成的?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 rubygems