diff --git a/app/models/artist.rb b/app/models/artist.rb index bdae643ee..573c9a511 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -18,7 +18,6 @@ class Artist < ActiveRecord::Base scope :other_names_match, lambda {|string| where(["other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string)])} scope :name_equals, lambda {|string| where("name = ?", string)} search_methods :url_match, :other_names_match - default_scope limit(1) module UrlMethods extend ActiveSupport::Concern diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 93d95916e..d4c71129a 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -1,7 +1,6 @@ class ArtistVersion < ActiveRecord::Base belongs_to :updater belongs_to :artist - default_scope limit(1) def updater_name User.id_to_name(updater_id).tr("_", " ") diff --git a/app/models/ban.rb b/app/models/ban.rb index 52118793c..5fb04e1c6 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -6,7 +6,6 @@ class Ban < ActiveRecord::Base validate :user_is_inferior validates_presence_of :user_id, :reason, :duration before_validation :initialize_banner_id, :on => :create - default_scope limit(1) def self.is_banned?(user) exists?(["user_id = ? AND expires_at > ?", user.id, Time.now]) diff --git a/app/models/comment.rb b/app/models/comment.rb index 191469df1..4557f5ff4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -8,7 +8,6 @@ class Comment < ActiveRecord::Base after_save :update_last_commented_at attr_accessible :body, :post_id attr_accessor :do_not_bump_post - default_scope limit(1) scope :recent, :order => "comments.id desc", :limit => 6 scope :body_matches, lambda {|query| where("body_index @@ plainto_tsquery(?)", query).order("comments.id DESC")} diff --git a/app/models/dmail.rb b/app/models/dmail.rb index f8978be18..3dce7fd75 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -21,7 +21,6 @@ class Dmail < ActiveRecord::Base scope :to_name_matches, lambda {|name| where("to_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)} scope :from_name_matches, lambda {|name| where("from_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)} search_method :to_name_matches, :from_name_matches - default_scope limit(1) module AddressMethods def to_name diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 79313b000..afc318856 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -14,7 +14,6 @@ class ForumPost < ActiveRecord::Base scope :for_user, lambda {|user_id| where("forum_posts.creator_id = ?", user_id)} scope :active, where("is_deleted = false") search_methods :body_matches - default_scope limit(1) def self.new_reply(params) if params[:topic_id] diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index e843186c7..2887c64cc 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -14,7 +14,6 @@ class ForumTopic < ActiveRecord::Base scope :active, where("is_deleted = false") search_methods :title_matches accepts_nested_attributes_for :original_post - default_scope limit(1) def editable_by?(user) creator_id == user.id || user.is_moderator? diff --git a/app/models/ip_ban.rb b/app/models/ip_ban.rb index 24ef7f742..6548e8aa2 100644 --- a/app/models/ip_ban.rb +++ b/app/models/ip_ban.rb @@ -3,7 +3,6 @@ class IpBan < ActiveRecord::Base before_validation :initialize_creator, :on => :create validates_presence_of :reason, :creator validates_uniqueness_of :ip_addr - default_scope limit(1) def self.is_banned?(ip_addr) exists?(["ip_addr = ?", ip_addr]) diff --git a/app/models/janitor_trial.rb b/app/models/janitor_trial.rb index 24e32e44c..37b65beac 100644 --- a/app/models/janitor_trial.rb +++ b/app/models/janitor_trial.rb @@ -6,7 +6,6 @@ class JanitorTrial < ActiveRecord::Base after_destroy :create_feedback validates_presence_of :user before_validation :initialize_creator - default_scope limit(1) def initialize_creator self.creator_id = CurrentUser.id diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index d06f1f2ba..529aac5ff 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -1,7 +1,6 @@ class ModAction < ActiveRecord::Base belongs_to :creator, :class_name => "User" before_validation :initialize_creator, :on => :create - default_scope limit(1) def initialize_creator self.creator_id = CurrentUser.id diff --git a/app/models/note.rb b/app/models/note.rb index 73383e52b..bd7e797fb 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -16,7 +16,6 @@ class Note < ActiveRecord::Base scope :body_matches, lambda {|query| where("body_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))} scope :post_tag_match, lambda {|query| joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query)} search_methods :body_matches, :post_tag_match - default_scope limit(1) def presenter @presenter ||= NotePresenter.new(self) diff --git a/app/models/note_version.rb b/app/models/note_version.rb index 2f4f7425e..96076ac5e 100644 --- a/app/models/note_version.rb +++ b/app/models/note_version.rb @@ -2,7 +2,6 @@ class NoteVersion < ActiveRecord::Base before_validation :initialize_updater belongs_to :updater, :class_name => "User" scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} - default_scope limit(1) def initialize_updater self.updater_id = CurrentUser.id diff --git a/app/models/pool.rb b/app/models/pool.rb index 4e1db5b63..100c0f435 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -15,7 +15,6 @@ class Pool < ActiveRecord::Base attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default] attr_accessible :is_deleted, :as => [:janitor, :moderator, :admin] scope :active, where("is_active = true and is_deleted = false") - default_scope limit(1) def self.name_to_id(name) if name =~ /^\d+$/ diff --git a/app/models/pool_version.rb b/app/models/pool_version.rb index 9d86a0b42..c85cf236e 100644 --- a/app/models/pool_version.rb +++ b/app/models/pool_version.rb @@ -6,7 +6,6 @@ class PoolVersion < ActiveRecord::Base belongs_to :updater, :class_name => "User" before_validation :initialize_updater scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} - default_scope limit(1) def initialize_updater self.updater_id = CurrentUser.id diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index 8b3c31f99..6c838e036 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -10,7 +10,6 @@ class PostAppeal < ActiveRecord::Base validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post" scope :for_user, lambda {|user_id| where(["creator_id = ?", user_id])} scope :recent, lambda {where(["created_at >= ?", 1.day.ago])} - default_scope limit(1) def validate_creator_is_not_limited if appeal_count_for_creator >= Danbooru.config.max_appeals_per_day diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index b57f079c0..d5981e0f0 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -12,7 +12,6 @@ class PostFlag < ActiveRecord::Base scope :resolved, where("is_resolved = ?", true) scope :unresolved, where("is_resolved = ?", false) scope :old, lambda {where("created_at <= ?", 3.days.ago)} - default_scope limit(1) def update_post post.update_column(:is_flagged, true) diff --git a/app/models/tag.rb b/app/models/tag.rb index 317d9bb21..32fbd0bb9 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -5,7 +5,6 @@ class Tag < ActiveRecord::Base scope :name_matches, lambda {|name| where("name LIKE ? ESCAPE E'\\\\'", name.downcase.to_escaped_for_sql_like)} scope :named, lambda {|name| where("name = ?", TagAlias.to_aliased([name]).join(""))} search_methods :name_matches - default_scope limit(1) class CategoryMapping Danbooru.config.reverse_tag_category_mapping.each do |value, category| diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index a3e73543a..22a855b21 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -9,7 +9,6 @@ class TagAlias < ActiveRecord::Base belongs_to :creator, :class_name => "User" scope :name_matches, lambda {|name| where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)} search_method :name_matches - default_scope limit(1) def self.to_aliased(names) alias_hash = Cache.get_multi(names.flatten, "ta") do |name| diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 28fbe65af..fdad4e4f2 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -8,7 +8,6 @@ class TagImplication < ActiveRecord::Base validate :absence_of_circular_relation scope :name_matches, lambda {|name| where("(antecedent_name = ? or consequent_name = ?)", name.downcase, name.downcase)} search_method :name_matches - default_scope limit(1) module DescendantMethods extend ActiveSupport::Concern diff --git a/app/models/tag_subscription.rb b/app/models/tag_subscription.rb index 4d14bc9ab..2ca79027c 100644 --- a/app/models/tag_subscription.rb +++ b/app/models/tag_subscription.rb @@ -6,7 +6,6 @@ class TagSubscription < ActiveRecord::Base before_save :limit_tag_count attr_accessible :name, :tag_query, :post_ids, :is_visible_on_profile validates_presence_of :name, :tag_query, :is_public, :creator_id - default_scope limit(1) def normalize_name self.name = name.gsub(/\W/, "_") diff --git a/app/models/upload.rb b/app/models/upload.rb index f4e63c6c1..9e8a9d8af 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -14,7 +14,6 @@ class Upload < ActiveRecord::Base validate :uploader_is_not_limited scope :uploaded_by, lambda {|user_id| where(["uploader_id = ?", user_id])} scope :pending, where(:status => "pending") - default_scope limit(1) module ValidationMethods def uploader_is_not_limited diff --git a/app/models/user.rb b/app/models/user.rb index 303cc35c4..1be6744b8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -45,7 +45,6 @@ class User < ActiveRecord::Base scope :with_email, lambda {|email| email.blank? ? where("FALSE") : where(["email = ?", email])} scope :find_for_password_reset, lambda {|name, email| email.blank? ? where("FALSE") : where(["name = ? AND email = ?", name, email])} search_method :named - default_scope limit(1) module BanMethods def validate_ip_addr_is_not_banned diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index ff31cd6cb..5cbf9eb86 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -10,7 +10,6 @@ class UserFeedback < ActiveRecord::Base scope :neutral, where("category = ?", "neutral") scope :negative, where("category = ?", "negative") scope :for_user, lambda {|user_id| where("user_id = ?", user_id)} - default_scope limit(1) def initialize_creator self.creator_id = CurrentUser.id diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index f7ba826a2..2ea7b494f 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -12,7 +12,6 @@ class WikiPage < ActiveRecord::Base has_one :tag, :foreign_key => "name", :primary_key => "title" has_one :artist, :foreign_key => "name", :primary_key => "title" has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC" - default_scope limit(1) def self.build_relation(options = {}) relation = where() diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index 96e17be36..d48472802 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -2,7 +2,6 @@ class WikiPageVersion < ActiveRecord::Base belongs_to :wiki_page belongs_to :updater, :class_name => "User" scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} - default_scope limit(1) def updater_name User.id_to_name(updater_id)