最佳答案
class Whatever < ActiveRecord::Base
validates :there_can_only_be_one
private
def there_can_only_be_one
errors.add_to_base('There can only be one') if Whatever.count > 0
end
end
class Whatever < ActiveRecord::Base
validates :there_can_only_be_one
private
def there_can_only_be_one
errors.add_to_base('There can only be one') if Whatever.count > 0
end
end