我目前正在开发可安装引擎。在发动机我有以下两种模式: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
这些数据库迁移文件:
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
的问题,当我尝试检索相关的对象开始。 作为一个例子,当我打电话@channel.get :categories
我收到以下错误:
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
正如你可以看到它的缺失关闭链接表isolate_namespace价值,因为它应该寻找在桌子上ems_categories_channels
不categories_channels
协会
任何人都有类似的问题,或者我错过了什么?
我没有看到,您的引擎是否包含'isolate_namespace'本身? 模块埃姆斯 类引擎<滑轨::引擎 isolate_namespace埃姆斯 结束 结束 – 2012-03-24 10:37:25