2012-07-13 6 views
17

Redmineを1.3.0から2.0.0にアップグレードしようとしていますが、データベースの移行に問題があります。私はコマンドを実行すると:ここActiveRecord :: SubclassNotFound

ActiveRecord::SubclassNotFound (The single-table inheritance mechanism failed to locate the subclass: 'GoogleAppsAuthSource'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite AuthSource.inheritance_column to use another column for that information.): 
app/models/user.rb:139:in `try_to_login' 
app/controllers/account_controller.rb:143:in `password_authentication' 
app/controllers/account_controller.rb:138:in `authenticate_user' 
app/controllers/account_controller.rb:30:in `login' 

は、私は私の古いで使用していたプラグインのリストである:

rake db:migrate RAILS_ENV=production 

rake aborted! 
uninitialized constant RAILS_ENV 

私のエラーログがあるように、それはエラーを示しredmine:

  1. Google Appsプラグイン

  2. Redmineのコードレビューのプラグイン

  3. Redmineのハドソンプラグイン

単一テーブル継承のエラーはおそらくあなたのデータベースにtypeという列によって引き起こされる私に

答えて

14

を助けてください。

typeという名前のカラムがrailsに見つかると、そのカラムはサブクラスを持つモデルであるとみなされ、タイプによって使用するモデルが識別されます。元々はレールのために作られていなかったプラグインのなかには、typeという列があり、それが原因でRailsが失敗することがあります。

62

誰がここでつまずく場合はタイプという名前の列を使用しないでください問題

  1. を修正するには、2つの方法があります。
  2. 手動では無意味なものに列名を設定します。

    self.inheritance_column = :_type_disabled 
    

    参照:http://apidock.com/rails/ActiveRecord/Base/inheritance_column/class

+2

'self.inheritance_column = nil'もトリックを行います。 – Amir

+1

'inheritance_column'でハックするのではなく' table_type'の名前を変更するほうが簡単です。これをnilとシンボルで試して、アプリケーションを別の領域で継承したモデルを壊しました。 –

+3

'typeというカラムを使用しないでください.'ありがとうございます...... –