Created
April 1, 2014 07:14
-
-
Save kazuhisa/9909317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SongTagValidator < ActiveModel::Validator | |
def validate(record) | |
if record.tags.size > 10 | |
record.errors[:base] << 'タグは10こまでです' | |
end | |
end | |
end |
コードまでありがとうございます!
コレをSongsTagでかければいいんでしょうか?
いや、Songモデルじゃろ?
ま、たぶん上手く動かないよこれ。
どういう現象が発生するかを教えて。
了解しました!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
新規登録時と更新時でrecord.tagsで期待通りの値が取れるか自信がない。