Ricky Spanish Ricky Spanish - 1 year ago 153
Ruby Question

Rails: rename globalize column

The rails globalize gem docs are great, but I can't find a solution, what I have to do, when I want to rename a column.

Last Year I did that, to add the translation fields.

def up
remove_column :news, :name
News.add_translation_fields! name: :string

def down
add_column :news, :name, :string, default: nil
remove_column :news_translations, :name

Now I want to rename the column "name" to "title", without loosing my data and translations. How do I have to write the migration file?

Answer Source

Alter the column on the news translations table directly:

def change
  rename_column :news_translations, :name, :title
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download