rails acts_as_follower postgres throw错误

时间:2014-03-03 06:38:39

标签: postgresql ruby-on-rails-4 devise

尝试将acts_as_follower gem添加到rails 4应用程序 - 我收到此错误

环境:

  • rails 4
  • 的PostgreSQL
  • acts_as_follower(0.2.1)
  • 色器件

用户模型充当跟随者并跟随

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)

1 个答案:

答案 0 :(得分:0)

在开发模式下,您可以运行

rake db:drop db:create db:migrate

更新您的种子数据,然后运行

rake db:seed