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

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

Closed
mcmegavolt opened this Issue Aug 13, 2013 · 8 comments

Comments

Projects
None yet
3 participants
@mcmegavolt

mcmegavolt commented Aug 13, 2013

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

This comment has been minimized.

Member

parndt commented Aug 13, 2013

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

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

This comment has been minimized.

mcmegavolt commented Aug 14, 2013

no, I just use

gem 'globalize3'

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

@mcmegavolt

This comment has been minimized.

mcmegavolt commented Aug 14, 2013

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

This comment has been minimized.

Contributor

shioyama commented Aug 14, 2013

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

This comment has been minimized.

mcmegavolt commented Aug 14, 2013

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

@shioyama

This comment has been minimized.

Contributor

shioyama commented Oct 25, 2013

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

This comment has been minimized.

mcmegavolt commented Oct 25, 2013

Yeah, thank you!

@shioyama

This comment has been minimized.

Contributor

shioyama commented Oct 25, 2013

Great, thanks!

@shioyama shioyama closed this Oct 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment