has_and_belongs_to_many
我的Ruby On Rails 项目中的关联有问题。
这是我的模型:
class Store < ActiveRecord::Base
attr_accessible :address, :city, :map_url, :name, :uimage_url
has_and_belongs_to_many :furnitures_id
end
class Furniture < ActiveRecord::Base
attr_accessible :description, :image_url, :maintenance, :name, :size
has_and_belongs_to_many :store_id
end
这是我的连接表迁移:
create_table "furnitures_stores", :id => false, :force => true do |t|
t.integer "furniture_id"
t.integer "store_id"
end
然后我尝试用seed.rb插入一些值:
Furniture.delete_all
furnitures = Furniture.create([{name: 'aaaa 1'}])
Store.delete_all
storee = Store.create([{name: 'S 1'}])
但它不起作用;我有这个错误:
**rake aborted!
uninitialized constant Store::FurnituresId**