Closed chris19960730 closed 4 years ago
Hi, I am using the acts-as-taggable-on in my model. I would like to validate every image has at least a tag. What should I do?
Here is my code: class Image < ApplicationRecord acts_as_taggable_on :tags validates :name, presence: true validates :url, presence: true
class Image < ApplicationRecord
acts_as_taggable_on :tags
validates :name, presence: true
validates :url, presence: true
Because tags is not an attribute in the Image table, it associate with Image by acts_as_taggable_on :tags
How can I add presence check to it? Thanks!
Hi, I am using the acts-as-taggable-on in my model. I would like to validate every image has at least a tag. What should I do?
Here is my code:
class Image < ApplicationRecord
acts_as_taggable_on :tags
validates :name, presence: true
validates :url, presence: true
Because tags is not an attribute in the Image table, it associate with Image by
acts_as_taggable_on :tags
How can I add presence check to it? Thanks!