我有以下型号:
class Group < ActiveRecord::Base
extend Enumerize
enumerize :kind, in: [:functional, :technical], predicates: true
belongs_to :ration
belongs_to :company
has_many :group_animal_keys
has_many :animal_keys, through: :group_animal_keys
accepts_nested_attributes_for :group_animal_keys
accepts_nested_attributes_for :animal_keys
validates :name, presence: true
validates :ration_id, presence: true, if: :functional_group?
scope :functional_groups, -> {where(kind: :functional)}
scope :technical_groups, -> {where(kind: :technical)}
def functional_group?
kind == 'functional'
end
end
自从我(使用标准Capistrano设置)部署到我们的服务器后,此模型的行为就像它没有代码一样。我可以创建一个实例,但Group.new.valid?
会返回true
,Group.first.ration
会生成一个undefined method ration
。 Group.functional_groups
也会返回undefined method published
。
知道可能出现什么问题吗?该模型在开发过程中表现正常。
答案 0 :(得分:0)
我发现了这个问题。
由于某种原因,app文件夹中的某个地方还有另一个空的group.rb
,它也继承自ActiveRecord
。