Class: Comment
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Comment
- Defined in:
- app/models/comment.rb
Overview
Comment attached to a state machine Comments can be private (not visible by the requester) -in order to be used for discussing the final decision- or public -allowing two way communication with the requester-.
Instance Attribute Summary collapse
- #body ⇒ Text
- #created_at ⇒ DateTime
- #machine_type ⇒ String
- #private ⇒ Boolean
- #updated_at ⇒ DateTime
- #user_id ⇒ Object readonly
Belongs to collapse
-
#machine ⇒ Machine
The associated state machine (request, reimbursement...).
-
#user ⇒ User
The author of the note.
Class Method Summary collapse
-
.newest_first ⇒ ActiveRecord::Relation<Comment>
A relation of Comments that are newest first.
-
.oldest_first ⇒ ActiveRecord::Relation<Comment>
A relation of Comments that are oldest first.
Instance Method Summary collapse
-
#public? ⇒ Boolean
Checks if the comment is public.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes
Instance Attribute Details
#body ⇒ Text
Validations:
15 |
# File 'app/models/comment.rb', line 15 validates :body, :user_id, :machine, presence: true |
#created_at ⇒ DateTime
67 |
# File 'db/schema.rb', line 67 t.datetime "created_at" |
#machine_type ⇒ String
64 |
# File 'db/schema.rb', line 64 t.string "machine_type" |
#private ⇒ Boolean
69 |
# File 'db/schema.rb', line 69 t.boolean "private" |
#updated_at ⇒ DateTime
68 |
# File 'db/schema.rb', line 68 t.datetime "updated_at" |
#user_id ⇒ Object (readonly)
15 |
# File 'app/models/comment.rb', line 15 validates :body, :user_id, :machine, presence: true |
Class Method Details
.newest_first ⇒ ActiveRecord::Relation<Comment>
A relation of Comments that are newest first. Active Record Scope
24 |
# File 'app/models/comment.rb', line 24 scope :newest_first, -> { order('created_at desc, id desc') } |
.oldest_first ⇒ ActiveRecord::Relation<Comment>
A relation of Comments that are oldest first. Active Record Scope
23 |
# File 'app/models/comment.rb', line 23 scope :oldest_first, -> { order('created_at asc, id asc') } |
Instance Method Details
#machine ⇒ Machine
The associated state machine (request, reimbursement...)
Validations:
11 |
# File 'app/models/comment.rb', line 11 belongs_to :machine, polymorphic: true, inverse_of: :comments |
#public? ⇒ Boolean
Checks if the comment is public
29 30 31 |
# File 'app/models/comment.rb', line 29 def public? !private end |