Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个名为 test.rb 的模型,当我在控制器中使用 @tests=Test.new 时,出现以下错误。有人可以解决这个问题吗?“Test:Module 的未定义方法‘新’”
看起来 test 已经是一个名为 Test 的模块的名称,如果您似乎有命名冲突。尝试将您自己的模型放入模块中,即
module MyModule class Test < ActiveRecord::Base end end
然后像这样称呼它
@test = MyModule::Test.new