hummingbird-me/kitsu-server

View on GitHub
app/models/community_recommendation_request.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class CommunityRecommendationRequest < ApplicationRecord
  include WithActivity
  include DescriptionSanitation

  belongs_to :user, required: true
  has_many :community_recommendations

  validates :description, presence: true
  validates :title, presence: true

  def feed
    @feed ||= CommunityRecommendationRequestFeed.new(id)
  end

  def stream_activity
    user.profile_feed.activities.new(
      title: title
    )
  end

  after_create do
    CommunityRecommendationFollow.create(
      user: user,
      community_recommendation_request: self
    )
  end
end