Class: Vote
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Vote
- Defined in:
- app/models/vote.rb
Overview
== Schema Information
Table name: votes
Database name: primary
id :bigint not null, primary key
resource_type :string
value :integer
customer_id :integer
resource_id :integer
Indexes
by_rid_rt_cid (resource_id,resource_type,customer_id)
idx_customer_id_resource_type (customer_id,resource_type)
Constant Summary collapse
- RESOURCE_TYPES =
Polymorphic owner allow-list. The (resource_type, resource_id) pair has no
database FK, so pin the type here to block_typeinjection and stale
strings after a model rename (see doc/tasks/202607041714_POLYMORPHIC_FK_INTEGRITY_AUDIT.md). %w[Article].freeze
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #resource_type ⇒ Object readonly
Belongs to collapse
Class Method Summary collapse
-
.negative ⇒ ActiveRecord::Relation<Vote>
A relation of Votes that are negative.
-
.positive ⇒ ActiveRecord::Relation<Vote>
A relation of Votes that are positive.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#resource_type ⇒ Object (readonly)
25 |
# File 'app/models/vote.rb', line 25 validates :resource_type, inclusion: { in: RESOURCE_TYPES }, allow_nil: true |
Class Method Details
.negative ⇒ ActiveRecord::Relation<Vote>
A relation of Votes that are negative. Active Record Scope
28 |
# File 'app/models/vote.rb', line 28 scope :negative, -> { where('value < 0') } |
.positive ⇒ ActiveRecord::Relation<Vote>
A relation of Votes that are positive. Active Record Scope
27 |
# File 'app/models/vote.rb', line 27 scope :positive, -> { where('value > 0') } |
Instance Method Details
#resource ⇒ Resource
23 |
# File 'app/models/vote.rb', line 23 belongs_to :resource, polymorphic: true, optional: true |