关联是在类定义中创建的,在运行脚本时将始终对其进行评估。重要的是,关联类定义需要有必要的表。因此,表的创建方法应该位于关联定义的顶层。首先,我认为这是一个相当糟糕的解决方案,因为我的方法调用和类定义位于同一个名称空间中。如果我试图分离类定义,我会得到No database associated with Sequel::Model错误(这是有道理的,但我想推迟对关联定义的评估,在表调用之后,只要它们
但是我得到了以下错误:
Unable to identify the primary key for table 'dbo.spt_fallback_db'.Unable to identify the primary key for table 'dbo.spt_fallback_dev'.Unable to identify the primary key for table 'dbo.spt_fallback_usg'.Unable to