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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – ActiveScaffold:如何为多态关联创建下拉选择?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试创建一个下拉选择框,用于与ActiveScaffold进行多态关联.

我有:

@H_404_4@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中创建选择下拉框时
有:

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

我收到以下错误

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

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

非常感谢一些建议.

解决方法

我不熟悉ActiveScaffold ……但是,他们的文档中的快速传递揭示了一个关于has_many的部分:我熟悉ActiveRecords …所以对于它的价值,你的多态关联应该是多少像这样写的?: @H_404_4@class Organization has_many :awards,:through => :sponsorship end class Individual has_many :awards,:through => :sponsorship end
原文链接:https://www.f2er.com/ruby/267620.html

猜你在找的Ruby相关文章