mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.96k stars 1.2k forks source link

Question about presence validates #1001

Closed chris19960730 closed 4 years ago

chris19960730 commented 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

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!