काम नहीं कर रहा है मुझे रूबी ऑन रेल परियोजना में has_and_belongs_to_many
एसोसिएशन के साथ समस्या है।has_and_belongs_to_many assocation
यहाँ मेरी मॉडल हैं:
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