指定与控制器名称所示不同的模型
我有一个名为“ResourcesController”的控制器,但它实际上管理两个不同模型的 CRUD。
我实际上没有一个名为 Resource 的模型,因此控制器犹豫是否找不到它。
有没有办法告诉控制器我将使用哪个模型,这样它就不会崩溃?
发布的错误是这样的:
NameError in ResourcesController#new
uninitialized constant Resource
这是目前的控制器:
class ResourcesController < ApplicationController
def new
end
end
I've got a controller called "ResourcesController", but its really managing the CRUD for two different models.
I don't actually have a model called Resource, so the controller is balking that it can't find it.
Is there a way I can inform the controller which model I'll be working with so it doesn't freak out?
The error that is posted is this:
NameError in ResourcesController#new
uninitialized constant Resource
Here is the controller at the moment:
class ResourcesController < ApplicationController
def new
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论