Sha256: 9350ad8817a9bcc3a03d63302b94f2bbebfe1fa23572cd61699ac444a84ed296

Contents?: true

Size: 377 Bytes

Versions: 1

Compression:

Stored size: 377 Bytes

Contents

module MyForum
  class Post < ActiveRecord::Base
    belongs_to  :topic, :counter_cache => true
    belongs_to  :user, :counter_cache => true

    after_create :update_topic_latest_post

    default_scope { where(is_deleted: false) }

    PER_PAGE = 2

    private

    def update_topic_latest_post
      self.topic.update_attribute(:latest_post_id, self.id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_forum-0.0.1.beta45 app/models/my_forum/post.rb