Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globalize doesn't allow migration to run #36

Open
pupeno opened this issue Aug 24, 2010 · 3 comments
Open

Globalize doesn't allow migration to run #36

pupeno opened this issue Aug 24, 2010 · 3 comments

Comments

@pupeno
Copy link

pupeno commented Aug 24, 2010

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
Copy link

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
Copy link

Worked for me! Thanks Robin!

@v3rtx
Copy link

v3rtx commented Mar 30, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants