class RuboCop::Cop::Rails::ActiveRecordAliases
book.update!(author: ‘Alice’)
# good
book.update_attributes!(author: ‘Alice’)
# bad
@example
`update` but the method name remained same in the method definition.
This cop is unsafe because custom ‘update_attributes` method call was changed to
@safety
are more clear and easier to read.
Checks that ActiveRecord aliases are not used. The direct method names
def on_send(node)
def on_send(node) return if node.arguments.empty? method_name = node.method_name alias_method = ALIASES[method_name] add_offense( node.loc.selector, message: format(MSG, prefer: alias_method, current: method_name), severity: :warning ) do |corrector| corrector.replace(node.loc.selector, alias_method) end end