Rail models

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 solve this? "undefined method` new 'for Test: Module "


source to share

1 answer

It looks like the test is already the name of a module called Test if it looks like you have a name conflict. Try to place your own model in a module i.e.

module MyModule
  class Test < ActiveRecord::Base  


and then calling it like that

@test = MyModule::Test.new




All Articles