ruby-on-rails – ActiveScaffold:如何为多态关联创建下拉选择?

我正在尝试创建一个下拉选择框,用于与ActiveScaffold进行多态关联.

我有

class Award
  belongs_to :sponsorship,:polymorphic => :true
end

class Organization
  has_many :awards,:as => :sponsorship
end

class Individual
  has_many :awards,:as => :sponsorship
end

尝试在awards_controller中创建选择下拉框时
有:

config.columns[:sponsorship].form_ui = :select

我收到以下错误

ActionView::TemplateError
(uninitialized constant
Award::Sponsorship)

我不确定这是我做得不对或我正在尝试的事情
完成不直接支持AS.

非常感谢一些建议.

解决方法

我不熟悉ActiveScaffold ……但是,他们的文档中的快速传递揭示了一个关于has_many的部分:我熟悉ActiveRecords …所以对于它的价值,你的多态关联应该是多少像这样写的?:
class Organization
  has_many :awards,:through => :sponsorship
end

class Individual
  has_many :awards,:through => :sponsorship
end

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...