Class: Integral::Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::Post
- Extended by:
- FriendlyId
- Includes:
- ActionView::Helpers::DateHelper, BlockEditor::Listable, Webhook::Observable
- Defined in:
- app/models/integral/post.rb
Overview
Represents a user post
Instance Method Summary collapse
- #frontend_url ⇒ Object
-
#increment_count!(ip_address) ⇒ Object
Increments the view count of the post if a PostViewing is successfully added.
-
#tag_context ⇒ String
Current tag context.
-
#tags ⇒ Array
ActsAsTaggableOn::Tag tags associated with this post.
-
#to_list_item ⇒ Hash
The instance as a list item.
- #to_param ⇒ Object
Methods included from Webhook::Delivery
#deliver_webhook, #deliver_webhook_event
Methods inherited from ApplicationRecord
Instance Method Details
#frontend_url ⇒ Object
83 84 85 86 |
# File 'app/models/integral/post.rb', line 83 def frontend_url route = Integral.multilingual_frontend? ? "post_#{locale}_url" : 'post_url' Integral::Engine.routes.url_helpers.send(route, slug) end |
#increment_count!(ip_address) ⇒ Object
Increments the view count of the post if a PostViewing is successfully added
66 67 68 |
# File 'app/models/integral/post.rb', line 66 def increment_count!(ip_address) increment!(:view_count) if PostViewing.add(self, ip_address) end |
#tag_context ⇒ String
Returns Current tag context.
89 90 91 |
# File 'app/models/integral/post.rb', line 89 def tag_context "#{status}_#{locale}" end |
#tags ⇒ Array
Returns ActsAsTaggableOn::Tag tags associated with this post.
94 95 96 |
# File 'app/models/integral/post.rb', line 94 def (tag_context) end |
#to_list_item ⇒ Hash
Returns the instance as a list item.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/integral/post.rb', line 71 def to_list_item subtitle = published_at.present? ? I18n.t('integral.blog.posted_ago', time: time_ago_in_words(published_at)) : I18n.t('integral.statuses.draft') { id: id, title: title, subtitle: subtitle, description: description, image: featured_image&., url: frontend_url } end |
#to_param ⇒ Object
98 99 100 |
# File 'app/models/integral/post.rb', line 98 def to_param id end |