2015-08-15 42 views
0

我使用blogit gem作爲我的博客解決方案,但事實證明,只顯示博客是不夠的,我需要對這些博客做幾件事情。現在我需要與blogit數據庫建立一對多的關係。我試圖寫:如何在我的模型`has_many`或`belongs_to`關係屬性中使用gem模型?

class BlogPost < ActiveRecord::Base 
    belongs_to :blogit_posts 
    mount_uploader :avatar, ProductImageUploader 
    belongs_to :featured_blog_post 
end 

但在活動管理員我收到以下錯誤:uninitialized constant BlogPost::BlogitPost。我認爲這是建立這種關係的失敗。

那麼在我的模型has_manybelongs_to關係屬性中使用寶石模型的正確方法是什麼?

回答

1

所有我需要做的就是添加一個class_name

belongs_to :blogit_post, class_name: "Blogit::Post" 
相關問題