继承的资源和多个belongs_to没有嵌套
让我们开始讨论实际问题吧。
Rails:2.3.11
我有一个控制器,使用inherited_resources 来引用两个单独的非嵌套资源。
我的控制器如图所示:
class Tools::DeploymentLinesController < ToolsController
inherit_resources
belongs_to :deployment
belongs_to :ticket
end#Tools::DeploymentLinesController
但是,inherit_resources
假设 belongs_to :ticket
是 deployment
的嵌套资源。
有没有办法在我的控制器中使用两个belongs_to
而不嵌套?或者我是否需要编写自己的业务逻辑来解决丢失的inherited_resources 关联?
Let's get down to brass tacks.
Rails: 2.3.11
I have a controller using inherited_resources to reference two separate and non-nested resources.
My controller is as shown:
class Tools::DeploymentLinesController < ToolsController
inherit_resources
belongs_to :deployment
belongs_to :ticket
end#Tools::DeploymentLinesController
However, inherit_resources
is assuming that the belongs_to :ticket
is a nested resource of deployment
.
Is there any way of using two belongs_to
in my controller without nesting? Or do I need to write out my own business logic to account for a missing inherited_resources association?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用:
You should be able to use: