diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2b60927e1..1a322042e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base # This is raised on requests to `/blah.js`. Rails has already rendered StaticController#not_found # here, so calling `rescue_exception` would cause a double render error. - rescue_from ActionController::InvalidCrossOriginRequest, :with => lambda {} + rescue_from ActionController::InvalidCrossOriginRequest, with: -> {} protected diff --git a/app/helpers/wiki_page_versions_helper.rb b/app/helpers/wiki_page_versions_helper.rb index d184eacb5..f23886c82 100644 --- a/app/helpers/wiki_page_versions_helper.rb +++ b/app/helpers/wiki_page_versions_helper.rb @@ -14,7 +14,7 @@ module WikiPageVersionsHelper cbo = Diff::LCS::ContextDiffCallbacks.new diffs = thisarr.diff(otharr, cbo) - escape_html = lambda {|str| str.gsub(/&/,'&').gsub(//,'>')} + escape_html = ->(str) {str.gsub(/&/,'&').gsub(//,'>')} output = thisarr output.each { |q| q.replace(escape_html[q]) } diff --git a/app/models/artist.rb b/app/models/artist.rb index a0aeb4a78..8dbb59e51 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -16,16 +16,16 @@ class Artist < ApplicationRecord belongs_to_creator has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name" has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl" - has_many :versions, lambda {order("artist_versions.id ASC")}, :class_name => "ArtistVersion" + has_many :versions, -> {order("artist_versions.id ASC")}, :class_name => "ArtistVersion" has_one :wiki_page, :foreign_key => "title", :primary_key => "name" has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name" has_one :tag, :foreign_key => "name", :primary_key => "name" attribute :notes, :string - scope :active, lambda { where(is_active: true) } - scope :deleted, lambda { where(is_active: false) } - scope :banned, lambda { where(is_banned: true) } - scope :unbanned, lambda { where(is_banned: false) } + scope :active, -> { where(is_active: true) } + scope :deleted, -> { where(is_active: false) } + scope :banned, -> { where(is_banned: true) } + scope :unbanned, -> { where(is_banned: false) } module UrlMethods extend ActiveSupport::Concern diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb index 16547ae77..fba316ac3 100644 --- a/app/models/artist_commentary.rb +++ b/app/models/artist_commentary.rb @@ -6,8 +6,8 @@ class ArtistCommentary < ApplicationRecord before_validation :trim_whitespace validates_uniqueness_of :post_id belongs_to :post, required: true - has_many :versions, lambda {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id - has_one :previous_version, lambda {order(id: :desc)}, :class_name => "ArtistCommentaryVersion", :foreign_key => :post_id, :primary_key => :post_id + has_many :versions, -> {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id + has_one :previous_version, -> {order(id: :desc)}, :class_name => "ArtistCommentaryVersion", :foreign_key => :post_id, :primary_key => :post_id after_save :create_version after_commit :tag_post diff --git a/app/models/artist_commentary_version.rb b/app/models/artist_commentary_version.rb index d8a9ab6ad..806eadabc 100644 --- a/app/models/artist_commentary_version.rb +++ b/app/models/artist_commentary_version.rb @@ -1,7 +1,7 @@ class ArtistCommentaryVersion < ApplicationRecord belongs_to :post belongs_to_updater - scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} + scope :for_user, ->(user_id) {where("updater_id = ?", user_id)} def self.search(params) q = super diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index d9a78b0f6..d31b1e060 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -8,7 +8,7 @@ class BulkUpdateRequest < ApplicationRecord validates_presence_of :user validates_presence_of :script - validates_presence_of :title, :if => lambda {|rec| rec.forum_topic_id.blank?} + validates_presence_of :title, if: ->(rec) {rec.forum_topic_id.blank?} validates_inclusion_of :status, :in => %w(pending approved rejected) validate :script_formatted_correctly validate :forum_topic_id_not_invalid @@ -17,10 +17,10 @@ class BulkUpdateRequest < ApplicationRecord before_validation :normalize_text after_create :create_forum_topic - scope :pending_first, lambda { order(Arel.sql("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)")) } - scope :pending, ->{where(status: "pending")} - scope :expired, ->{where("created_at < ?", TagRelationship::EXPIRY.days.ago)} - scope :old, ->{where("created_at between ? and ?", TagRelationship::EXPIRY.days.ago, TagRelationship::EXPIRY_WARNING.days.ago)} + scope :pending_first, -> { order(Arel.sql("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)")) } + scope :pending, -> {where(status: "pending")} + scope :expired, -> {where("created_at < ?", TagRelationship::EXPIRY.days.ago)} + scope :old, -> {where("created_at between ? and ?", TagRelationship::EXPIRY.days.ago, TagRelationship::EXPIRY_WARNING.days.ago)} module SearchMethods def default_order diff --git a/app/models/comment.rb b/app/models/comment.rb index 7149b7ff5..a252d0233 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -9,17 +9,17 @@ class Comment < ApplicationRecord belongs_to_updater has_many :votes, :class_name => "CommentVote", :dependent => :destroy after_create :update_last_commented_at_on_create - after_update(:if => lambda {|rec| (!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |rec| + after_update(:if => ->(rec) {(!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |rec| ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}",:comment_update) end - after_save :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.saved_change_to_is_deleted?} - after_save(:if => lambda {|rec| rec.is_deleted? && rec.saved_change_to_is_deleted? && CurrentUser.id != rec.creator_id}) do |rec| + after_save :update_last_commented_at_on_destroy, :if => ->(rec) {rec.is_deleted? && rec.saved_change_to_is_deleted?} + after_save(:if => ->(rec) {rec.is_deleted? && rec.saved_change_to_is_deleted? && CurrentUser.id != rec.creator_id}) do |rec| ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}",:comment_delete) end mentionable( :message_field => :body, - :title => lambda {|user_name| "#{creator_name} mentioned you in a comment on post ##{post_id}"}, - :body => lambda {|user_name| "@#{creator_name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.excerpt(body, "@"+user_name)}\n[/quote]\n"}, + :title => ->(user_name) {"#{creator_name} mentioned you in a comment on post ##{post_id}"}, + :body => ->(user_name) {"@#{creator_name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:\n\n[quote]\n#{DText.excerpt(body, "@"+user_name)}\n[/quote]\n"}, ) module SearchMethods diff --git a/app/models/favorite.rb b/app/models/favorite.rb index bc713882b..ed1ac6828 100644 --- a/app/models/favorite.rb +++ b/app/models/favorite.rb @@ -1,7 +1,7 @@ class Favorite < ApplicationRecord belongs_to :post belongs_to :user - scope :for_user, lambda {|user_id| where("user_id % 100 = #{user_id.to_i % 100} and user_id = #{user_id.to_i}")} + scope :for_user, ->(user_id) {where("user_id % 100 = #{user_id.to_i % 100} and user_id = #{user_id.to_i}")} def self.add(post:, user:) Favorite.transaction do diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index dddab2d00..a260e266d 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -19,16 +19,16 @@ class ForumPost < ApplicationRecord validate :topic_is_not_restricted, :on => :create before_destroy :validate_topic_is_unlocked after_save :delete_topic_if_original_post - after_update(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do |rec| + after_update(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |rec| ModAction.log("#{CurrentUser.name} updated forum ##{rec.id}",:forum_post_update) end - after_destroy(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do |rec| + after_destroy(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |rec| ModAction.log("#{CurrentUser.name} deleted forum ##{rec.id}",:forum_post_delete) end mentionable( :message_field => :body, - :title => lambda {|user_name| %{#{creator_name} mentioned you in topic ##{topic_id} (#{topic.title})}}, - :body => lambda {|user_name| %{@#{creator_name} mentioned you in topic ##{topic_id} ("#{topic.title}":[/forum_topics/#{topic_id}?page=#{forum_topic_page}]):\n\n[quote]\n#{DText.excerpt(body, "@"+user_name)}\n[/quote]\n}}, + :title => ->(user_name) {%{#{creator_name} mentioned you in topic ##{topic_id} (#{topic.title})}}, + :body => ->(user_name) {%{@#{creator_name} mentioned you in topic ##{topic_id} ("#{topic.title}":[/forum_topics/#{topic_id}?page=#{forum_topic_page}]):\n\n[quote]\n#{DText.excerpt(body, "@"+user_name)}\n[/quote]\n}}, ) module SearchMethods diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index 06c603d3f..4ccff0664 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -13,8 +13,8 @@ class ForumTopic < ApplicationRecord belongs_to_creator belongs_to_updater - has_many :posts, lambda {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id", :dependent => :destroy - has_one :original_post, lambda {order("forum_posts.id asc")}, class_name: "ForumPost", foreign_key: "topic_id", inverse_of: :topic + has_many :posts, -> {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id", :dependent => :destroy + has_one :original_post, -> {order("forum_posts.id asc")}, class_name: "ForumPost", foreign_key: "topic_id", inverse_of: :topic has_many :subscriptions, :class_name => "ForumSubscription" before_validation :initialize_is_deleted, :on => :create validates_presence_of :title, :creator_id @@ -24,7 +24,7 @@ class ForumTopic < ApplicationRecord validates :title, :length => {:maximum => 255} accepts_nested_attributes_for :original_post after_update :update_orignal_post - after_save(:if => lambda {|rec| rec.is_locked? && rec.saved_change_to_is_locked?}) do |rec| + after_save(:if => ->(rec) {rec.is_locked? && rec.saved_change_to_is_locked?}) do |rec| ModAction.log("locked forum topic ##{id} (title: #{title})",:forum_topic_lock) end diff --git a/app/models/ip_ban.rb b/app/models/ip_ban.rb index dac2d0190..da073b2e0 100644 --- a/app/models/ip_ban.rb +++ b/app/models/ip_ban.rb @@ -3,7 +3,7 @@ class IpBan < ApplicationRecord belongs_to_creator validates_presence_of :reason, :creator, :ip_addr validates_format_of :ip_addr, :with => IP_ADDR_REGEX - validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX} + validates_uniqueness_of :ip_addr, :if => ->(rec) {rec.ip_addr =~ IP_ADDR_REGEX} after_create do |rec| ModAction.log("#{CurrentUser.name} created ip ban for #{rec.ip_addr}",:ip_ban_create) end diff --git a/app/models/news_update.rb b/app/models/news_update.rb index fcf5e514a..5e0fecb09 100644 --- a/app/models/news_update.rb +++ b/app/models/news_update.rb @@ -1,5 +1,5 @@ class NewsUpdate < ApplicationRecord belongs_to_creator belongs_to_updater - scope :recent, lambda {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)} + scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)} end diff --git a/app/models/note.rb b/app/models/note.rb index 142ea0cbe..e894db891 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -7,7 +7,7 @@ class Note < ApplicationRecord belongs_to :post belongs_to_creator belongs_to_updater - has_many :versions, lambda {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy + has_many :versions, -> {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height, :body validate :post_must_exist validate :note_within_image diff --git a/app/models/note_version.rb b/app/models/note_version.rb index 31cc22caf..45f386744 100644 --- a/app/models/note_version.rb +++ b/app/models/note_version.rb @@ -1,6 +1,6 @@ class NoteVersion < ApplicationRecord belongs_to_updater :counter_cache => "note_update_count" - scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} + scope :for_user, ->(user_id) {where("updater_id = ?", user_id)} def self.search(params) q = super diff --git a/app/models/post.rb b/app/models/post.rb index cb2a9c9a6..3fcf8ddb9 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -52,8 +52,8 @@ class Post < ApplicationRecord has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy has_many :votes, :class_name => "PostVote", :dependent => :destroy has_many :notes, :dependent => :destroy - has_many :comments, lambda {includes(:creator, :updater).order("comments.id")}, :dependent => :destroy - has_many :children, lambda {order("posts.id")}, :class_name => "Post", :foreign_key => "parent_id" + has_many :comments, -> {includes(:creator, :updater).order("comments.id")}, :dependent => :destroy + has_many :children, -> {order("posts.id")}, :class_name => "Post", :foreign_key => "parent_id" has_many :approvals, :class_name => "PostApproval", :dependent => :destroy has_many :disapprovals, :class_name => "PostDisapproval", :dependent => :destroy has_many :favorites @@ -85,7 +85,7 @@ class Post < ApplicationRecord end if PostArchive.enabled? - has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy + has_many :versions, -> {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy end module FileMethods diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb index 776508c76..91ed364a9 100644 --- a/app/models/post_disapproval.rb +++ b/app/models/post_disapproval.rb @@ -7,10 +7,10 @@ class PostDisapproval < ApplicationRecord validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post" validates_inclusion_of :reason, :in => %w(legacy breaks_rules poor_quality disinterest) - scope :with_message, lambda {where("message is not null and message <> ''")} - scope :breaks_rules, lambda {where(:reason => "breaks_rules")} - scope :poor_quality, lambda {where(:reason => "poor_quality")} - scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])} + scope :with_message, -> {where("message is not null and message <> ''")} + scope :breaks_rules, -> {where(:reason => "breaks_rules")} + scope :poor_quality, -> {where(:reason => "poor_quality")} + scope :disinterest, -> {where(:reason => ["disinterest", "legacy"])} def initialize_attributes self.user_id ||= CurrentUser.user.id diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index 38a0c7056..644b3b6a1 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -19,9 +19,9 @@ class PostFlag < ApplicationRecord before_save :update_post attr_accessor :is_deletion - scope :by_users, lambda { where.not(creator: User.system) } - scope :by_system, lambda { where(creator: User.system) } - scope :in_cooldown, lambda { by_users.where("created_at >= ?", COOLDOWN_PERIOD.ago) } + scope :by_users, -> { where.not(creator: User.system) } + scope :by_system, -> { where(creator: User.system) } + scope :in_cooldown, -> { by_users.where("created_at >= ?", COOLDOWN_PERIOD.ago) } module SearchMethods def reason_matches(query) diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb index 872d3dd12..af030f916 100644 --- a/app/models/saved_search.rb +++ b/app/models/saved_search.rb @@ -52,7 +52,7 @@ class SavedSearch < ApplicationRecord after_save {|rec| Cache.delete(SavedSearch.cache_key(rec.user_id))} after_destroy {|rec| Cache.delete(SavedSearch.cache_key(rec.user_id))} before_validation :normalize - scope :labeled, lambda {|label| where("labels @> string_to_array(?, '~~~~')", label)} + scope :labeled, ->(label) { where("labels @> string_to_array(?, '~~~~')", label)} def self.normalize_label(label) label.to_s.strip.downcase.gsub(/[[:space:]]/, "_") diff --git a/app/models/tag.rb b/app/models/tag.rb index 1a4d3ef66..82c7a04b6 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -5,15 +5,15 @@ class Tag < ApplicationRecord SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm|flagger|-flagger|appealer|-appealer" has_one :wiki_page, :foreign_key => "title", :primary_key => "name" has_one :artist, :foreign_key => "name", :primary_key => "name" - has_one :antecedent_alias, lambda {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name" - has_many :consequent_aliases, lambda {active}, :class_name => "TagAlias", :foreign_key => "consequent_name", :primary_key => "name" - has_many :antecedent_implications, lambda {active}, :class_name => "TagImplication", :foreign_key => "antecedent_name", :primary_key => "name" - has_many :consequent_implications, lambda {active}, :class_name => "TagImplication", :foreign_key => "consequent_name", :primary_key => "name" + has_one :antecedent_alias, -> {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name" + has_many :consequent_aliases, -> {active}, :class_name => "TagAlias", :foreign_key => "consequent_name", :primary_key => "name" + has_many :antecedent_implications, -> {active}, :class_name => "TagImplication", :foreign_key => "antecedent_name", :primary_key => "name" + has_many :consequent_implications, -> {active}, :class_name => "TagImplication", :foreign_key => "consequent_name", :primary_key => "name" validates :name, uniqueness: true, tag_name: true, on: :create validates_inclusion_of :category, in: TagCategory.category_ids - after_save :update_category_cache_for_all, if: lambda {|rec| rec.saved_change_to_attribute?(:category)} + after_save :update_category_cache_for_all, if: ->(rec) { rec.saved_change_to_attribute?(:category)} module ApiMethods def to_legacy_json diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index 7e84d4b41..091c01dfc 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -21,9 +21,9 @@ class TagRelationship < ApplicationRecord before_validation :normalize_names validates_format_of :status, :with => /\A(active|deleted|pending|processing|queued|error: .*)\Z/ validates_presence_of :creator_id, :antecedent_name, :consequent_name - validates :creator, presence: { message: "must exist" }, if: lambda { creator_id.present? } - validates :approver, presence: { message: "must exist" }, if: lambda { approver_id.present? } - validates :forum_topic, presence: { message: "must exist" }, if: lambda { forum_topic_id.present? } + validates :creator, presence: { message: "must exist" }, if: -> { creator_id.present? } + validates :approver, presence: { message: "must exist" }, if: -> { approver_id.present? } + validates :forum_topic, presence: { message: "must exist" }, if: -> { forum_topic_id.present? } def initialize_creator self.creator_id = CurrentUser.user.id diff --git a/app/models/user.rb b/app/models/user.rb index 053199c9c..5151fbd1d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,15 +68,15 @@ class User < ApplicationRecord after_initialize :initialize_attributes, if: :new_record? validates :name, user_name: true, on: :create - validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present? && rec.saved_change_to_email? } - validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || rec.password.present?} + validates_uniqueness_of :email, :case_sensitive => false, :if => ->(rec) { rec.email.present? && rec.saved_change_to_email? } + validates_length_of :password, :minimum => 5, :if => ->(rec) { rec.new_record? || rec.password.present?} validates_inclusion_of :default_image_size, :in => %w(large original) validates_inclusion_of :per_page, :in => 1..100 validates_confirmation_of :password - validates_presence_of :email, :if => lambda {|rec| rec.new_record? && Danbooru.config.enable_email_verification?} + validates_presence_of :email, :if => ->(rec) { rec.new_record? && Danbooru.config.enable_email_verification?} validates_presence_of :comment_threshold validate :validate_ip_addr_is_not_banned, :on => :create - validate :validate_sock_puppets, :on => :create, :if => lambda { Danbooru.config.enable_sock_puppet_validation? } + validate :validate_sock_puppets, :on => :create, :if => -> { Danbooru.config.enable_sock_puppet_validation? } before_validation :normalize_blacklisted_tags before_validation :set_per_page before_validation :normalize_email @@ -92,19 +92,19 @@ class User < ApplicationRecord has_many :post_approvals, :dependent => :destroy has_many :post_disapprovals, :dependent => :destroy has_many :post_votes - has_many :bans, lambda {order("bans.id desc")} - has_one :recent_ban, lambda {order("bans.id desc")}, :class_name => "Ban" + has_many :bans, -> {order("bans.id desc")} + has_one :recent_ban, -> {order("bans.id desc")}, :class_name => "Ban" has_one :api_key has_one :dmail_filter has_one :super_voter has_one :token_bucket has_many :note_versions, :foreign_key => "updater_id" - has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id" + has_many :dmails, -> {order("dmails.id desc")}, :foreign_key => "owner_id" has_many :saved_searches - has_many :forum_posts, lambda {order("forum_posts.created_at, forum_posts.id")}, :foreign_key => "creator_id" - has_many :user_name_change_requests, lambda {visible.order("user_name_change_requests.created_at desc")} - has_many :favorite_groups, lambda {order(name: :asc)}, foreign_key: :creator_id + has_many :forum_posts, -> {order("forum_posts.created_at, forum_posts.id")}, :foreign_key => "creator_id" + has_many :user_name_change_requests, -> {visible.order("user_name_change_requests.created_at desc")} + has_many :favorite_groups, -> {order(name: :asc)}, foreign_key: :creator_id belongs_to :inviter, class_name: "User", optional: true after_update :create_mod_action accepts_nested_attributes_for :dmail_filter diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index d80751590..b18bef408 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -8,10 +8,10 @@ class UserFeedback < ApplicationRecord validate :creator_is_gold validate :user_is_not_creator after_create :create_dmail - after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec| + after_update(:if => ->(rec) { CurrentUser.id != rec.creator_id}) do |rec| ModAction.log(%{#{CurrentUser.name} updated user feedback for "#{rec.user_name}":/users/#{rec.user_id}},:user_feedback_update) end - after_destroy(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec| + after_destroy(:if => ->(rec) { CurrentUser.id != rec.creator_id}) do |rec| ModAction.log(%{#{CurrentUser.name} deleted user feedback for "#{rec.user_name}":/users/#{rec.user_id}},:user_feedback_delete) end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 1ecea6631..b65c3045b 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -13,8 +13,8 @@ class WikiPage < ApplicationRecord validate :validate_not_locked attr_accessor :skip_secondary_validations has_one :tag, :foreign_key => "name", :primary_key => "title" - has_one :artist, lambda {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title" - has_many :versions, lambda {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy + has_one :artist, -> {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title" + has_many :versions, -> {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy module SearchMethods def titled(title) diff --git a/app/presenters/wiki_page_presenter.rb b/app/presenters/wiki_page_presenter.rb index f70822be3..690dbecf5 100644 --- a/app/presenters/wiki_page_presenter.rb +++ b/app/presenters/wiki_page_presenter.rb @@ -19,7 +19,7 @@ class WikiPagePresenter cbo = Diff::LCS::ContextDiffCallbacks.new diffs = thisarr.diff(otharr, cbo) - escape_html = lambda {|str| str.gsub(/&/,'&').gsub(//,'>')} + escape_html = ->(str) {str.gsub(/&/,'&').gsub(//,'>')} output = thisarr; output.each { |q| q.replace(CGI.escape_html(q)) } diff --git a/config/application.rb b/config/application.rb index 1550f2c93..408263aab 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,7 +21,7 @@ module Danbooru config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = {:enable_starttls_auto => false} config.action_mailer.perform_deliveries = true - config.log_tags = [lambda {|req| "PID:#{Process.pid}"}] + config.log_tags = [->(req) {"PID:#{Process.pid}"}] config.action_controller.action_on_unpermitted_parameters = :raise config.force_ssl = true diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index f306c195a..e2d5de04f 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -101,7 +101,7 @@ SimpleForm.setup do |config| # config.item_wrapper_class = nil # How the label text should be generated altogether with the required text. - # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + # config.label_text = ->(label, required, explicit_label) { "#{required} #{label}" } # You can define the class to use on all labels. Default is nil. # config.label_class = nil diff --git a/test/functional/post_replacements_controller_test.rb b/test/functional/post_replacements_controller_test.rb index 1ef51801f..a36c41726 100644 --- a/test/functional/post_replacements_controller_test.rb +++ b/test/functional/post_replacements_controller_test.rb @@ -26,7 +26,7 @@ class PostReplacementsControllerTest < ActionDispatch::IntegrationTest } } - assert_difference(lambda { @post.replacements.size }) do + assert_difference(-> { @post.replacements.size }) do post_auth post_replacements_path, @user, params: params @post.reload end