-1

Does anyone know about this stuff, I'm getting frustrated by it.

DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead.(called from <top (required)> at /**/config/environment.rb:12)
==  FillAppIdInCampaignPrices: migrating -  ===================================

rake aborted!

An error has occurred, this and all later migrations canceled:

private method `import' called for #<Class:0x007fc9285fdfe0>

I've already changed from this:

set_table_name

to this:

self.table_name = 'the_name'

==================================================================================

This is environment.rb:

require File.expand_path('../application', __FILE__)

 require 'octopus' 

require Rails.root + 'lib/utils'

PublisServer::Application.initialize!

And this the migration:

class AddApprovedToContents < ActiveRecord::Migration

  class Content < ActiveRecord::Base

    self.table_name = 'contents'

  end

  def up

    add_column :contents, :approved, :boolean, default: false

    add_column :articles, :approved, :boolean, default: false

    Content.update_all approved: true

    Article.update_all approved: true

  end


  def down

    remove_column :contents, :approved

    remove_column :articles, :approved

  end

end

I can't find FillAppIdInCampaignPrices: migrating I dont know where is come from.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
agstwn21
  • 123
  • 1
  • 14
  • The deprecation warning is only a warning; it's not raising the error. You've cut off the error message before the good parts. What comes after `private method import called`? – Zach Kemp Mar 18 '14 at 05:07
  • 3
    The error will tell you the line causing the problem, or at least give you a starting point. We need to see that, plus the source code that generates it. Without those we can't help you. – the Tin Man Mar 18 '14 at 05:08
  • @theTinMan : hey Tina Man, i already put the source – agstwn21 Mar 18 '14 at 06:07
  • @ZachKemp: so the deprecation is ok – agstwn21 Mar 18 '14 at 06:08

1 Answers1

0

I've never created such an intricate migration as you've presented, but I have to ask why "why" you have Contact class in a migration?

According to this documentation, you can use models in your migrations like this:

class AddApprovedToContents < ActiveRecord::Migration

  def up
    add_column :contents, :approved, :boolean, default: false
    add_column :articles, :approved, :boolean, default: false
    reversible do |dir|
       dir.up {
           Content.update_all approved: true
           Article.update_all approved: true
       }
    end
  end

  def down
    remove_column :contents, :approved
    remove_column :articles, :approved
  end

end
Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • thx for the answer. do you mean content right? coz i dont have Contact class it's content class, it's use for set the table name "content table" – agstwn21 Mar 20 '14 at 03:32