Class: Vote

Inherits:
ApplicationRecord show all
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)

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.negativeActiveRecord::Relation<Vote>

A relation of Votes that are negative. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Vote>)

See Also:



22
# File 'app/models/vote.rb', line 22

scope :negative, -> { where('value < 0') }

.positiveActiveRecord::Relation<Vote>

A relation of Votes that are positive. Active Record Scope

Returns:

  • (ActiveRecord::Relation<Vote>)

See Also:



21
# File 'app/models/vote.rb', line 21

scope :positive, -> { where('value > 0') }

Instance Method Details

#resourceResource

Returns:

  • (Resource)

See Also:



19
# File 'app/models/vote.rb', line 19

belongs_to :resource, polymorphic: true, optional: true