diff --git a/app/controllers/bans_controller.rb b/app/controllers/bans_controller.rb index c5c9ed402..74effffbd 100644 --- a/app/controllers/bans_controller.rb +++ b/app/controllers/bans_controller.rb @@ -33,7 +33,6 @@ class BansController < ApplicationController if @ban.update_attributes(params[:ban]) redirect_to ban_path(@ban), :notice => "Ban updated" else - puts @ban.errors.full_messages render :action => "edit" end end diff --git a/app/models/comment.rb b/app/models/comment.rb index ff3aa2272..b57ba3195 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -84,8 +84,6 @@ class Comment < ActiveRecord::Base end def update_last_commented_at - puts Comment.where("post_id = ?", post_id).count - puts !do_not_bump_post? if Comment.where("post_id = ?", post_id).count == 0 Post.update_all("last_commented_at = NULL", ["id = ?", post_id]) elsif Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post? diff --git a/app/models/post.rb b/app/models/post.rb index 76ef75139..0f2d85158 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -8,6 +8,7 @@ class Post < ActiveRecord::Base after_destroy :delete_remote_files after_save :create_version after_save :update_parent_on_save + after_save :apply_metatags, :on => :create before_save :merge_old_tags before_save :normalize_tags before_save :create_tags @@ -380,13 +381,15 @@ class Post < ActiveRecord::Base end def filter_metatags(tags) - metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|rating|fav|parent):/} - apply_metatags(metatags) + @metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|rating|fav|parent):/} + apply_metatags return tags end - def apply_metatags(tags) - tags.each do |tag| + def apply_metatags + return unless @metatags.is_a?(Array) + + @metatags.each do |tag| case tag when /^parent:none$/, /^parent:0$/ self.parent_id = nil diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 79cb8eb0d..8cf609b70 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -2,7 +2,7 @@ module Danbooru module Extensions module String def to_escaped_for_sql_like - return self.gsub(/\\/, '\0\0').gsub(/(%|_)/, '\\\\\\1').gsub(/_/, '\\_').gsub(/\*/, '%') + return self.gsub(/\\/, '\0\0').gsub(/(%|_)/, "\\\\\\1").gsub(/\*/, '%') end def to_escaped_js