【发布时间】:2016-02-19 15:36:54
【问题描述】:
class Game
field :name, type: String
field :region, type: String
field :county, type: String
field :state, type: String
field :sport, type: String
# if sport equals football
validates :name, presence: true, uniqueness: {scope: [:region, :state]}
# if sport equals baseball
validates :name, presence: true, uniqueness: {scope: [:county, :state]}
我们如何才能实现特定于某项运动的名称的唯一性,但具有地区和州或县和州的范围?
【问题讨论】:
-
我不明白为什么这被否决了?