Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

undefined method `set_table_name' while migrating (Rails 4) #261

Closed
mcmegavolt opened this Issue · 8 comments

3 participants

@mcmegavolt

when I run migration I get error:

undefined method `set_table_name' for Article::Category::Translation(Table doesn't exist): Class /home/user/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'

My code:

models/article/category.rb

class Article::Category < ActiveRecord::Base
    translates :name, :description
end

migration file

class TranslateCategories < ActiveRecord::Migration
  def self.up
    Article::Category.create_translation_table!({
      :name => :string,
      :description => :text
    }, {
      :migrate_data => true
    })
  end

  def self.down
    Article::Category.drop_translation_table! :migrate_data => true
  end
end
@parndt
Owner

Which version of Globalize are you using? Are you using the rails4 branch? In Gemfile:

gem 'globalize3', github: 'svenfuchs/globalize3', branch: 'rails4'
@mcmegavolt

no, I just use

gem 'globalize3'

sory, I have not found gem installing instructions for Rails 4 before :)

@mcmegavolt

When I use your solution, I get error while bundle update

Could not find gem 'paper_trail (~> 3.0.0.beta) ruby', which is required by gem 'globalize3 (>= 0) ruby', in any of the sources.
@shioyama
Owner

You have to also use the latest version of paper_trail by explicitly putting it in your gemfile, like this:

gem 'paper_trail', github: 'airblade/paper_trail', branch: 'master'

See the rails4 branch readme.

@mcmegavolt

Thnks, it worked!
One more question, do I need :name and :description fields in original article_categories table?

@shioyama
Owner

If you have migrated your data to the translations table, you should no longer need the name and description columns in the original table.

Also FYI, the rails4 branch is now master, and we've created a new globalize gem with major version numbers locked to AR numbers, so you can just use:

gem 'globalize', '~> 4.0.0.alpha.2'

Can I close this?

@mcmegavolt

Yeah, thank you!

@shioyama
Owner

Great, thanks!

@shioyama shioyama closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.