Skip to content

Commit a0dffe9

Browse files
committed
use attribute_name rather than attribute
1 parent 1c4f976 commit a0dffe9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/rails/deprecate_errors_as_hash.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
```ruby
1919
book.errors.add(:title, 'is not interesting enough.')
2020
book.errors.map(&:full_message)
21-
book.errors.map(&:attrobite)
21+
book.errors.map(&:attribite_names)
2222
book.errors.delete(:comments)
2323
```
2424
EOS
@@ -49,7 +49,7 @@
4949
receiver: { node_type: 'call_node', name: 'errors', arguments: nil },
5050
name: 'keys',
5151
arguments: nil do
52-
replace_with '{{receiver}}.map(&:attribute)'
52+
replace_with '{{receiver}}.map(&:attribute_names)'
5353
end
5454

5555
with_node node_type: 'call_node',

spec/rails/deprecate_errors_as_hash_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def create
2222
@post = Post.create(post_params)
2323
@post.errors.add(:title, 'is not interesting enough.')
2424
@post.errors.delete(:comments)
25-
render json: { fields: @post.errors.map(&:attribute), errors: @post.errors.map(&:message) }
25+
render json: { fields: @post.errors.map(&:attribute_names), errors: @post.errors.map(&:message) }
2626
end
2727
end
2828
EOS

0 commit comments

Comments
 (0)