How to rename model How to rename model ruby-on-rails ruby-on-rails

How to rename model


update: this script is not supported anymore

A script exists that will do the job for you:

http://github.com/hiroshi/script-refactor


You'll have to change all the references to Users in all your application manually.

To change the name by itself, it's not very hard : rename the file and add the following migration :

class RenameUsers < ActiveRecord::Migration    def self.up        rename_table :users, :user    end    def self.down        rename_table :user, :users    endend


You need to rename your file, your test/spec file and all reference to this model.

You also need to make a migration to rename the table.