From 07921d2c88f4e464ecf73be7f4a1cfcec981dc1d Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Oct 2016 04:57:07 -0500 Subject: [PATCH] Make rating:s obey rate locks; make source:blah update pixiv id. Move normalize_tags (which processes metatags) from before_save to before_validation. This is so that it runs as early as possible, before strip_source / parse_pixiv_ids / updater_can_change_rating, so these callbacks can handle source/rating changes from metatags. Fixes a couple bugs: * Ratings locks were ignored when using rating:s metatag (regression in 0006b76) * Pixiv ids weren't updated when using source:blah metatag. Note: this means that `post.update_attribute(:tag_string => "art:bkub)` is now wrong. This is because update_attribute runs callbacks but not validations, so it doesn't process metatags from the tag string. `update` or `update_attributes` must be used instead. --- app/models/post.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 4f58c59aa..73efe797e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -7,8 +7,10 @@ class Post < ActiveRecord::Base class RevertError < Exception ; end class SearchError < Exception ; end - before_validation :strip_source before_validation :initialize_uploader, :on => :create + before_validation :merge_old_changes + before_validation :normalize_tags + before_validation :strip_source before_validation :parse_pixiv_id before_validation :blank_out_nonexistent_parents before_validation :remove_parent_loops @@ -16,8 +18,6 @@ class Post < ActiveRecord::Base validates_inclusion_of :rating, in: %w(s q e), message: "rating must be s, q, or e" validate :post_is_not_its_own_parent validate :updater_can_change_rating - before_save :merge_old_changes - before_save :normalize_tags before_save :update_tag_post_counts before_save :set_tag_counts before_save :set_pool_category_pseudo_tags