I'm trying to rename the columns in a Rails project, and I generated migration files and bundle exec rake db:migrate
.
Procedures are like this.
generate file,
bin/rails g migration RenameUserTwitterNameToName
and write the method with column names,
def change
rename_column :users, :twitter_name, :name
end
finally execute the rake task.
bundle exec rake db:migrate
Although it works well, I need to modify the controllers related to the columns.
For example, if there is a code like below, I need to change the method find_by_twitter_name
to find_by_name
@user = User.find_by_twitter_name(name)
Is there any way to modify the controller like above automatically?