2014-03-03 40 views
0

只是嘗試添加acts_as_follower寶石的軌道4應用程序 - 並且正在此錯誤軌acts_as_follower的Postgres拋出錯誤

環境:

  • 軌道4
  • PostgreSQL的
  • acts_as_follower(0.2.1 )
  • devise

用戶模型作爲追隨者,以下

PG::NotNullViolation at /follows 
ERROR: null value in column "followable_id" violates not-null constraint 
DETAIL: Failing row contains (4, null, null, 21, User, f, 2014-03-03 06:35:49.655726, 2014-03-03 06:35:49.655726). 

我的代碼:

class User < ActiveRecord::Base 
    acts_as_follower 
    acts_as_followable 
end 

follower = User.first 
following= User.last 
follower.follow(following) 
+0

我懷疑它不喜歡被添加t o現有數據模型在安裝gem之前已經有數據。但這只是一個猜測,我從來沒有使用它(或Rails)。 –

回答

0

在開發模式下,你可以運行

rake db:drop db:create db:migrate 

更新您的種子數據,然後運行

rake db:seed