Post History
I saw this report about a bug in an error message and figured that would be an easy fix. The incorrect error message is: "Tags can't have more than 5 tags". That should be "Posts can't have...". ...
#1: Initial revision
How should I fix this incorrect error message (don't quite understand the code)
I saw [this report about a bug in an error message](https://meta.codidact.com/posts/287036) and figured that would be an easy fix. The incorrect error message is: "Tags can't have more than 5 tags". That should be "Posts can't have...". I figured I'd need to find and edit a string. I grepped the code and found my way to `app/models/post.rb`, which includes this: ``` def maximum_tags if tags_cache.length > 5 errors.add(:tags, "can't have more than 5 tags") elsif tags_cache.empty? errors.add(:tags, 'must have at least one tag') end end ``` What is `:tags` here? I don't see anything in this file that defines it, so it must be coming from somewhere else. (Have I mentioned I'm very much a newbie with Ruby and Rails?) I think the logic here is that the error is being _caused_ by tags validation, so we're adding it to a set of errors about that field. But we don't want to use the name of the field in the error message here. I realize it's possible to hack around this problem by changing the string here to a sentence that can legitimately begin with the word "Tags", but I'd rather understand what the correct change would be.