How to solve the `Object doesn't support #inspect` error?

前端 未结 3 1743
傲寒
傲寒 2020-12-20 05:34

I am using rails v3.2.2 and I get a strange error when I try to load associated records.

The following is the Terminal input/output I get:

1.9.2-p318         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-20 06:30

    The problem seems to be solved by stating the following in my Category::Article::ArticleRelationship:

    class Category::Article::ArticleRelationship < ActiveRecord::Base
      belongs_to :article,
        :class_name    => '::Article', # note I added '::'
        :foreign_key   => 'article_id'
    end
    

    but I didn't understand why?

提交回复
热议问题