added validation for tag count

This commit is contained in:
juandefelix
2015-10-03 11:54:48 -05:00
parent 78c186242f
commit 7db2fecbb1

View File

@@ -3,6 +3,7 @@ module Taggable
included do
acts_as_taggable
validate :max_number_of_tags
end
def tag_list_with_limit(limit = nil)
@@ -17,4 +18,8 @@ module Taggable
count = tags.size - limit
count < 0 ? 0 : count
end
def max_number_of_tags
errors.add(:tag_list, :less_than_or_equal_to, count: 6) if tag_list.count > 6
end
end