我尝试加入2代表在轨道上,但其成为IMPOSIBLE给我。错误连接中的Rails
我的模式是:
table "cursos"|
t.string "nombre"
t.integer "user_id"
end
table "users",
t.string "name"
end
user.rb:
class User < ActiveRecord::Base
has_many :cursos
curso.rb
class Curso < ActiveRecord::Base
belongs_to :user
def self.search(nameProf)
(Cursos.joins(:users).where("users.name ilike ?", "%#{nameProf}%").all)
end
它给我这个错误:
NameError in CursosController#index uninitialized constant Curso::Cursos
谢谢!
你的类被称为'Curso'所以将其更改为'CURSO .joins(:users)...' –
尝试以单数形式编写Curso。 – Navin
我试过了,它给我下面的错误:NoMethodError在CursosController#指数# 未定义的方法'叫” –
hernan