本文介绍了滑轨型号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为test.rb的模型,当我在控制器中使用@ tests = Test.new时,出现以下错误.有人可以我怎么解决这个问题吗? "Test:Module的未定义方法'new'"
i have a model named test.rb and when i use @tests=Test.new in my controller i get the following error. Can someone temme how can i resolve this? "undefined method `new' for Test:Module"
推荐答案如果似乎您的命名冲突,则好像test已经是一个名为Test的模块的名称.尝试将自己的模型放在模块中,即
Looks like test is already the name of a module called Test if would seem that you have naming conflict. Try placing your own model in a module ie
module MyModule class Test < ActiveRecord::Base end end然后这样称呼
@test = MyModule::Test.new更多推荐
滑轨型号
发布评论