0

我正在编写一个 Rails 应用程序。

我的模型树看起来像这样:

models/
|-  user.rb
|-  ...
|-  forum/
  |- thread.rb
  |- forum.rb

一个用户有很多线程。

当我尝试这个时:

has_many :forum_threads

尝试引用它时出现以下错误:

uninitialized constant User::ForumThread

但是,当我尝试这个时:

has_many :threads

我收到以下错误:

undefined method `scoped' for Thread:Class

我做错了什么?这可能是什么原因造成的?

4

1 回答 1

0

I've managed to solve it. I only had to add a :class_name specifier to the has_many decleration:

has_many :forum_threads, class_name: 'Forum::Thread'
于 2013-04-18T17:26:51.523 回答