7
Mam problem ze skojarzeniem has_and_belongs_to_many
w moim projekcie Ruby On Rails.ma_and_belongs_to_many asokacja nie działa
Oto moje modele:
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
To mój dołączyć migracja tabela:
create_table "furnitures_stores", :id => false, :force => true do |t|
t.integer "furniture_id"
t.integer "store_id"
end
Potem próbował wstawić niektóre wartości z seed.rb:
Furniture.delete_all
furnitures = Furniture.create([{name: 'aaaa 1'}])
Store.delete_all
storee = Store.create([{name: 'S 1'}])
Ale to nie działa; Mam ten błąd:
**rake aborted!
uninitialized constant Store::FurnituresId**
, ale jak mogę się odwołać do modelu? – Teo
@Teo Nie wiem co masz na myśli. –
Teraz rozumiem ... I działa ... Dzięki – Teo