Sie sind auf Seite 1von 2

create_table "ratings", force: :cascade do |t|

t.string "ratable_type"
t.bigint "ratable_id"
t.string "rated_by_type"
t.bigint "rated_by_id"
t.bigint "bid_id"
t.integer "score"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

Class User < ActiveRecord::Base


has_many :ratings, as: :ratable
has_many :given_ratings, class_name: 'Rating', as: 'rated_by'
end

Class Vendor < ActiveRecord::Base


has_many :ratings, as: :ratable
has_many :given_ratings, class_name: 'Rating', as: 'rated_by'
end
Class bid < ActiveRecord::Base
has_many :ratings
end

class Rating < ApplicationRecord


belongs_to :ratable, polymorphic: true
belongs_to :rated_by, polymorphic: true
belongs_to :bid
end

Das könnte Ihnen auch gefallen