Clarify why model[] is preferred over read_attribute#326
Clarify why model[] is preferred over read_attribute#326MarcPer wants to merge 1 commit intorubocop:masterfrom
Conversation
|
@pirj that's a good point, I can adapt the PR to take this into account. How about this?
|
|
I think this is unnecessary, the PR is good as is. |
|
After looking more into the Rails code, I found out the conclusion from the referenced discussion is not exactly correct. If I just try any random attribute with model[:wrong_attr]
# => nilThe person = Person.select('id').first
person[:name] # => ActiveModel::MissingAttributeError: missing attribute: nameThe important thing to realize is that the exception is only raised when |
Addresses #155