Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は自分のモデルにこれを持っています:
validates :polarity, presence: true
1and のみを許可したい-1(投票システムであるため)。
1
-1
それを達成する方法は?
コメントで提案されているように:
validates :polarity, presence: true, inclusion: { in: [-1, 1] }