【发布时间】:2011-12-13 09:34:20
【问题描述】:
我想限制用户可以创建的模型对象的数量。我已经尝试了以下方法,但它不起作用。我了解 Rails 3.1 中发生了一些变化,现在不知道如何实现。
class User < ActiveRecord::Base
has_many :things, :limit => 5, :dependent => :destroy # This doesn't work
end
class Things <ActiveRecord::Base
belongs_to :user
end
【问题讨论】:
标签: ruby-on-rails ruby activerecord ruby-on-rails-3.1 limit