# == Schema Information # # Table name: bookmarks # # id :integer not null, primary key # user_id :integer # bookmarkable_id :integer # bookmarkable_type :string # created_at :datetime not null # updated_at :datetime not null # class Bookmark < ActiveRecord::Base belongs_to :user, counter_cache: true belongs_to :bookmarkable, polymorphic: true validates_presence_of :user, :bookmarkable validates :user_id, uniqueness: { scope: [:bookmarkable_id, :bookmarkable_type] } end