joshmh / globalize2

The second incarnation of Globalize for Rails
http://www.globalize-rails.org/
MIT License
364 stars 57 forks source link

Globalize doesn't allow migration to run #36

Open pupeno opened 14 years ago

pupeno commented 14 years ago

I'm picking a project where there's a model called Project with three translated fields. These fields were translated at different times, so there are two migrations, one for two fields and one for another field. When I try to run the migrations I get a complaint about a missing field, which is in a later migration effectively having me stuck, no able to migrate (without having to change the code in a way that will fail later).

==  AddProjectTranslations: migrating =========================================
rake aborted!
An error has occurred, this and all later migrations canceled:

Missing translated field url
RobinClowers commented 12 years ago

FWIW I ran into this today and worked around it by declaring the model with only the original translations in the migration that creates the translation table.

class AddTranslationsForProject < ActiveRecord::Migration
  class Project < ActiveRecord::Base
    translates :name, :description
  end

  def self.up
    Project.create_translation_table! :name => :string, :description => :text
  end

  def self.down
    Project.drop_translation_table!
  end
end
gabrielengel commented 12 years ago

Worked for me! Thanks Robin!

v3rtx commented 9 years ago

Thanks Robin, adding translates attributes to the migration fixed all issues!