diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-03 00:17:10 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-03 00:17:10 -0300 |
commit | d56b5dacb1fbaeef9d48d57594b2f1f9c32a21bb (patch) | |
tree | 267e748f481c0e091b8635816747bd192a4ab9c5 | |
parent | 86062005a73589dc4919cfac401ce061f061c6a0 (diff) | |
download | rails-d56b5dacb1fbaeef9d48d57594b2f1f9c32a21bb.tar.gz rails-d56b5dacb1fbaeef9d48d57594b2f1f9c32a21bb.tar.bz2 rails-d56b5dacb1fbaeef9d48d57594b2f1f9c32a21bb.zip |
Use the `flat_map` method.
Thanks to @jeremy to teach me this one.
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 4762f39044..243d911f71 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -188,9 +188,9 @@ module ActiveModel # # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}> # # ] def validators_on(*attributes) - attributes.map do |attribute| + attributes.flat_map do |attribute| _validators[attribute.to_sym] - end.flatten + end end # Returns +true+ if +attribute+ is an attribute method, +false+ otherwise. |