<commit_before>module Forem
  class Forum < ActiveRecord::Base
    belongs_to :category
    has_many :topics, :dependent => :destroy
    has_many :posts, :through => :topics, :dependent => :destroy
    has_many :views, :through => :topics, :dependent => :destroy

    validates :title, :presence => true
    validates :description, :presence => true

    def last_post_for(current_user)
      current_user && current_user.forem_admin? ? posts.last : last_visible_post
    end

    def last_visible_post
      posts.where("forem_topics.hidden = ?", false).last
    end
  end
end
<commit_msg>Modified the Forem Model to include validation for category presence  #66<commit_after>module Forem
  class Forum < ActiveRecord::Base
    belongs_to :category
    has_many :topics, :dependent => :destroy
    has_many :posts, :through => :topics, :dependent => :destroy
    has_many :views, :through => :topics, :dependent => :destroy

    validates :category, :presence => true
    validates :title, :presence => true
    validates :description, :presence => true

    def last_post_for(current_user)
      current_user && current_user.forem_admin? ? posts.last : last_visible_post
    end

    def last_visible_post
      posts.where("forem_topics.hidden = ?", false).last
    end
  end
end

{'fraction_non_alphanumeric': 0.1044427123928293, 'fraction_numerical': 0.001558846453624318, 'mean_word_length': 3.8452830188679243, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3593397', 'n_tokens_mistral': 397, 'n_tokens_neox': 391, 'n_words': 104}