aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/finder_methods.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2014-10-28 16:17:33 -0700
committerXavier Noria <fxn@hashref.com>2014-10-28 16:35:24 -0700
commitb3bfa361c503e107aff4dee5edf79bd7fd3d3725 (patch)
tree4a9725f90708b45ff85e68b01335bbf94ee35f17 /activerecord/lib/active_record/relation/finder_methods.rb
parent777142d3a7b9ea36fcc8562613749299ac6dc243 (diff)
downloadrails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.tar.gz
rails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.tar.bz2
rails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.zip
let's warn with heredocs
The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
Diffstat (limited to 'activerecord/lib/active_record/relation/finder_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index c95ec2522b..ddb392a6d4 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -1,4 +1,5 @@
require 'active_support/deprecation'
+require 'active_support/core_ext/string/filters'
module ActiveRecord
module FinderMethods
@@ -284,8 +285,10 @@ module ActiveRecord
def exists?(conditions = :none)
if Base === conditions
conditions = conditions.id
- ActiveSupport::Deprecation.warn "You are passing an instance of ActiveRecord::Base to `exists?`." \
- "Please pass the id of the object by calling `.id`"
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ You are passing an instance of ActiveRecord::Base to `exists?`.
+ Please pass the id of the object by calling `.id`
+ MSG
end
return false if !conditions
@@ -435,8 +438,10 @@ module ActiveRecord
def find_one(id)
if ActiveRecord::Base === id
id = id.id
- ActiveSupport::Deprecation.warn "You are passing an instance of ActiveRecord::Base to `find`." \
- "Please pass the id of the object by calling `.id`"
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ You are passing an instance of ActiveRecord::Base to `find`.
+ Please pass the id of the object by calling `.id`
+ MSG
end
column = columns_hash[primary_key]