Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Script to rename model
3 Posts
Script to rename model

Hi,

When I one to add one column into a model, I use command like this: script/generate migration AddRoleToUser role:string

This will generate the migration, give it an appropriated name....Does Rails support a similar script to rename the entire model (and its corresponding view, controller if possible)? Some thing like this:

script/generate migration RenameAccountToUser

Thank you, Lam

Hey Lam,

There is something called rename_table that you can use in your migration to rename you tables, but then you will have to change the name of the models yourself. You can do this automatically by making dummy versions of your model inside the migration itself, but that would be complex. I wonder if there is an automated script lying in the wild that would do this automatically for you.

Searching around but no hope. Finally have to do it manually. Thanks for your comment anyway

3 Posts
Login to add your message