RubyMine 2023.2 Help

Rename refactorings

Use the Rename refactoring to change names of symbols, files, directories, Rails application components, Rails named scopes, Rails fixtures, and so on. RubyMine automatically changes all the references to renamed items throughout code.

Renaming local variables or private methods can be done easily inline since only the limited scope is affected. Renaming classes or public methods could potentially impact a lot of files. In this case, we suggest that you preview potential changes before you refactor.

The procedure below demonstrates how to rename a class method.

  1. Place a caret at the method name:

    place caret
  2. Press Shift+F6 or select Refactor | Rename... from the main menu.

  3. Specify a new method name in the invoked dialog and click Refactor:

    Rename dialog
  4. In the Refactoring Preview window, inspect code changes to be made and click Do Refactor:

    Refactoring Preview window

Example

Before

After

class Song def initialize(name, artist) @name = name @artist = artist end def to_s "Song: #{@name}--#{@artist}" end end song = Song.new("My Way", "Sinatra") puts song.to_s
class Song def initialize(name, artist) @name = name @artist = artist end def to_string "Song: #{@name}--#{@artist}" end end song = Song.new("My Way", "Sinatra") puts song.to_string
Last modified: 15 June 2023