7
Ruby On Rails projemde has_and_belongs_to_many
derneği ile ilgili bir sorunum var. İşte has_and_belongs_to_many dolamıyor çalışmıyor
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
Bu benim katılmak tablo göç:
create_table "furnitures_stores", :id => false, :force => true do |t|
t.integer "furniture_id"
t.integer "store_id"
end
Sonra seed.rb ile bazı değerleri eklemek için çalıştı:
Furniture.delete_all
furnitures = Furniture.create([{name: 'aaaa 1'}])
Store.delete_all
storee = Store.create([{name: 'S 1'}])
Ama işe yaramıyor;
**rake aborted!
uninitialized constant Store::FurnituresId**
ama nasıl modele başvurabilirim? – Teo
@Teo Ne demek istediğini anlamadım. –
Şimdi anlıyorum .. Ve işe yarıyor .. Teşekkürler – Teo