我目前正在開發可安裝引擎。在發動機我有以下兩種模式: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