[Ruby / Rails] Use alias. In a way that rubocop won't get angry!

environment

question

Should I use ʻalias, should I use ʻalias_method, should I define it with symbol or not?

This is the answer!

Use ʻalias and ** not ** symbol.

Instance method

  def existing_method
    ...
  end

  alias alias_method existing_method

Class method

  def self.existing_method
    ...
  end

  class << self
    alias alias_method existing_method
  end

Recommended Posts

[Ruby / Rails] Use alias. In a way that rubocop won't get angry!
Rails logger Get a rough idea in 1 minute
(Ruby on Rails6) Creating data in a table
I want to use a little icon in Rails
[Ruby / Rails] Set a unique (unique) value in the class
Use Coveralls with GitHub Actions in a Ruby repository
Use images in Rails
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
How to display a graph in Ruby on Rails (LazyHighChart)
Apply CSS to a specific View in Ruby on Rails
Get UserAgent in [Rails] controller
Use ruby variables in javascript.
Multiplication in a Ruby array
Use multiple checkboxes in Rails6!
[Rails] A simple way to implement a self-introduction function in your profile
A solution to Docker errors that beginners tend to get stuck in
I get a Ruby version error when I try to start Rails.
(Ruby on Rails6) Creating a database and displaying it in a view
[Ruby] Use an external API that returns JSON in HTTP request
How to get JDK 11 on your mac in a comfortable way