我正在尝试访问另一个目录中的类DealState和NotAnEndState,在该目录中有一个名为move-to-go的库。
move-to-go文件夹包含一些模块,在我的示例中该模块名为Deal_state.rb。当我打开Deal_state.rb时,它包含以下代码。
lib的路径:F:\ Ruby25-x64 \ lib \ ruby \ gems \ 2.5.0 \ gems \ move-to-go-5.3.0 \ lib \ move-to-go
module MoveToGo
module DealState
# This is the default, a deal with a status with this state is
# currently being worked on.
NotAnEndState = 0
# The deal has reached a positive end state, eg we have won
# the deal.
PositiveEndState = 1
# The deal has reached a negative end state, eg we have lost
# the deal.
NegativeEndState = -1
end
end
我的代码的路径:C:Users / Shahin / MigrationFolder / converter.rb
class Converter
def configure(rootmodel)
rootmodel.settings.with_organization do |organization|
organization.set_custom_field( { :integration_id => 'source', :title => 'Källa', :type => :Link } )
end
rootmodel.settings.with_person do |person|
person.set_custom_field( { :integration_id => 'source', :title => 'Källa', :type => :String} )
end
rootmodel.settings.with_deal do |deal|
assessment is default DealState::NotAnEndState
deal.add_status( {:label => '1. Kvalificering' })
deal.add_status( {:label => '2. Deal closed', :assessment => MoveToGo::DealState::PositiveEndState })
deal.add_status( {:label => '4. Deal lost', :assessment => MoveToGo::DealState::NegativeEndState })
end
end
执行脚本时,出现以下错误消息: C:Users / MyUserName / MigrationFolder / converter.rb:63:在'configure中的块'中:未初始化的常量Converter :: DealState(NameError) 你的意思是? DEAL_SHEET
然而,新事物已经暴露出来。该错误消息似乎与Converter-class有关,但是我无法真正解释它的含义。
答案 0 :(得分:0)
此行是错误:assessment is default DealState::NotAnEndState
。
首先,您应该使用MoveToGo::DealState::NotAnEndState
,第二个assessment is default
应该位于规格文件中。
如果您删除此行,就不会再有错误了。