Skip to content

Commit

Permalink
Fix featured tag form not failing on failed tag validations (mastodon…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Mar 5, 2019
1 parent 8edc744 commit 08d373b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/featured_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class FeaturedTag < ApplicationRecord

delegate :name, to: :tag, allow_nil: true

validates :name, presence: true
validates_associated :tag, on: :create
validates :name, presence: true, on: :create
validate :validate_featured_tags_limit, on: :create

def name=(str)
self.tag = Tag.find_or_initialize_by(name: str.delete('#').mb_chars.downcase.to_s)
self.tag = Tag.find_or_initialize_by(name: str.strip.delete('#').mb_chars.downcase.to_s)
end

def increment(timestamp)
Expand Down

0 comments on commit 08d373b

Please sign in to comment.