作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为与 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
config.columns[:sponsorship].form_ui = :select
ActionView::TemplateError (uninitialized constant Award::Sponsorship)
最佳答案
我不熟悉 ActiveScaffold ......但是,他们的文档中的快速传递揭示了一个关于 has_many 的部分:通过它我从 ActiveRecords 中熟悉......所以对于它的值(value),你的多态关联是否应该是是这样写的?:
class Organization
has_many :awards, :through => :sponsorship
end
class Individual
has_many :awards, :through => :sponsorship
end
关于ruby-on-rails - ActiveScaffold:如何为多态关联创建下拉选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2369488/
我是一名优秀的程序员,十分优秀!