Refactoring a Rails Project

Code evolves as technology and market demands evolve. Over time, existing code may need to be changed to allow more room to grow, to improve performance, to accommodate changing needs, or simply to clean up the code base. Refactoring is the term used to describe the process of redesigning existing code without changing its behavior from the user's point of view.

Refactoring may be small or extensive, but even small changes can introduce bugs. Refactoring must be done correctly and completely to be effective. One change can have permutations throughout the entire code base. Refactoring handles the entire set of permutations responsibly and durably, with safe operation, so that no behavior is changed beyond improvements in performance or maintainability.

Refactoring support is now expected in typed language IDEs but is not readily available in dynamic language IDEs. It is difficult to perform automated refactorings for dynamic languages since type information is not statically available. 3rdRail provides refactorings by performing advanced type inference (statically analyzing a program to determine types) and semantic type inference (statically analyzing a program in the context of the specific frameworks semantics).

For a demonstration of refactoring, see the video Refactor a Rails Action.

To perform a refactoring:

  1. Highlight the Rails Item:
  2. Right-click and select the Refactor menu.
  3. Choose type of refactoring (context sensitive selection):


    If the item selected is not a controller, view or action, the Rename Rails Item is displayed but disabled.

  4. In the Refactor Dialog review refactor information and modify the criteria as appropriate for the content.
  5. Click Preview to preview the refactor task.
    The Preview dialog provides a check list of all directories, files, declarations and usages affected by the refactoring. Select individual items to be removed from the refactoring. Click an item in the check list to reveal the original data and the described change (highlighted).
    Click OK to process the refactor task.


    Dynamic language refactoring can not be guaranteed to be 100% accurate. Testing after refactoring is encouraged.


    Where changes are not made in the Preview Dialog, Undo Refactoring from the workbench:

    Edit| Undo.

Corporate LogoCodeGear brand and product names are service marks, trademarks or registered trademarks of Borland Software Corporation in the United States and other countries.