7
내 Ruby On Rails 프로젝트에서 has_and_belongs_to_many
연관성에 문제가 있습니다. 여기 has_and_belongs_to_many assocation does not work
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**
하지만 모델을 어떻게 참조 할 수 있습니까? – Teo
@Teo 무슨 뜻인지 모르겠다. –
지금은 이해 .. 그리고 그것은 작동합니다 .. 감사합니다 Logged – Teo