Ruby on rails activeadmin多态类型比较
我有一个多态关联:Ruby on rails activeadmin多态类型比较,ruby-on-rails,ruby,activeadmin,Ruby On Rails,Ruby,Activeadmin,我有一个多态关联: class Option < ActiveRecord::Base belongs_to :structurable, polymorphic: true end 或 我想这会有帮助的 o.structurable.class == Animal 或 我想这会有帮助的 o.structurable.class == Animal 或 您也可以尝试使用此选项检查动物对象 o.structurable.kind_of?(Animal) 您也可以尝试使用此选项检查
class Option < ActiveRecord::Base
belongs_to :structurable, polymorphic: true
end
或
我想这会有帮助的
o.structurable.class == Animal
或
我想这会有帮助的
o.structurable.class == Animal
或
您也可以尝试使用此选项检查动物对象
o.structurable.kind_of?(Animal)
您也可以尝试使用此选项检查动物对象
o.structurable.kind_of?(Animal)
o.structurable.kind_of?(Animal)