現在、マウント可能なエンジンを開発中です。マウント可能なエンジンでHABTMリンクテーブルがisolate_namespace値を取らない
module Ems
class Channel < ActiveRecord::Base
has_and_belongs_to_many :categories
end
end
module Ems
class Category < ActiveRecord::Base
has_and_belongs_to_many :channels
end
end
これらは、DB移行ファイルです:私は、関連するオブジェクトを取得しようとすると、
class CreateEmsChannels < ActiveRecord::Migration
def change
create_table :ems_channels do |t|
t.string :slug
t.string :name
t.timestamps
end
end
end
class CreateEmsCategories < ActiveRecord::Migration
def change
create_table :ems_categories do |t|
t.string :slug
t.string :name
t.text :strapline
t.timestamps
end
end
end
class CreateEmsCategoriesChannels < ActiveRecord::Migration
def up
# Create the association table
create_table :ems_categories_channels, :id => false do |t|
t.integer :category_id, :null => false
t.integer :channel_id, :null => false
end
# Add table index
add_index :ems_categories_channels, [:category_id, :channel_id], :unique => true
end
end
問題が始まるエンジンの中で私は、次の2つのモデルがあります。それはテーブルems_categories_channels
ないcategories_channels
に関連探さなければならないとして、あなたは、リンクテーブルの上にそのがisolate_namespace値から外れ欠けて見ることができるように
Mysql2::Error: Table 'ems_development.categories_channels' doesn't exist:
SELECT `ems_categories`.*
FROM `ems_categories`
INNER JOIN `categories_channels`
ON `ems_categories`.`id` = `categories_channels`.`category_id`
WHERE `categories_channels`.`channel_id` = 1
:私は、私は次のエラーを取得する@channel.get :categories
を呼び出す例として 、
誰もが同様の問題を抱えていたか、何か不足していますか?
あなたのエンジンには 'isolate_namespace'自体が含まれていますか? モジュールエムス クラスエンジン