BigW Consortium Gitlab

users_star_project.rb 510 Bytes
Newer Older
Ciro Santilli committed
1 2 3 4
# == Schema Information
#
# Table name: users_star_projects
#
Dmitriy Zaporozhets committed
5 6 7 8 9
#  id         :integer          not null, primary key
#  project_id :integer          not null
#  user_id    :integer          not null
#  created_at :datetime
#  updated_at :datetime
Ciro Santilli committed
10 11 12
#

class UsersStarProject < ActiveRecord::Base
13
  belongs_to :project, counter_cache: :star_count, touch: true
Ciro Santilli committed
14 15 16 17 18 19
  belongs_to :user

  validates :user, presence: true
  validates :user_id, uniqueness: { scope: [:project_id] }
  validates :project, presence: true
end