create_table "deliveries", :force => true do |t|
t.string "name"
t.text "description"
end
create_table "shops", :force => true do |t|
t.string "name"
t.float "rating"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.string "password_digest"
end
create_table "delivery_per_shops", :force => true do |t|
t.integer "delivery_id"
t.integer "shop_id"
t.float "rating"
end
create_table "delivery_per_shops_per_users", :force => true do |t|
t.integer "rating"
t.integer "delivery_per_shop_id"
t.integer "user_id"
end
class Shop < ActiveRecord::Base
has_many :delivery_per_shops
has_many :deliveries, :through => :delivery_per_shops
end
class Delivery < ActiveRecord::Base
has_many :delivery_per_shops
has_many :shops, :through => :delivery_per_shops
end
class User < ActiveRecord::Base
has_many :delivery_per_shops_per_users
has_many :delivery_per_shops, :through => :delivery_per_shops_per_users
end
class DeliveryPerShop < ActiveRecord::Base
belongs_to :delivery
belongs_to :shop
has_many :delivery_per_shops_per_users
has_many :users, :through => :delivery_per_shops_per_users
end
class DeliveryPerShopsPerUsers < ActiveRecord::Base
belongs_to :delivery_per_shop
belongs_to :user
end
Rails 3.1.0. Что тут неверно? Про nested associations читал, но не сильно понял применимо ли это в моём случае.