Sha256: 2546485b8b171085d586a5f1b4c9fff701ee6416331afd537673f235c1cc68bc
Contents?: true
Size: 841 Bytes
Versions: 2
Compression:
Stored size: 841 Bytes
Contents
module MyForum class Topic < ActiveRecord::Base has_many :posts, :counter_cache => true, dependent: :destroy belongs_to :forum, :counter_cache => true belongs_to :user def info author = (post = posts.first).user.login created = post.created_at { author: author, created: created } end def owner posts.first.user end def unread?(current_user, last_post) return true unless current_user log = LogReadMark.where(user_id: current_user.id, topic_id: self.id, post_id: last_post.id).count log >= 1 ? false : true end def mark_as_read(current_user, last_topic) return true unless current_user log = LogReadMark.find_or_create_by(user_id: current_user.id, topic_id: self.id) log.post_id = last_topic.id log.save end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
my_forum-0.0.1.beta2 | app/models/my_forum/topic.rb |
my_forum-0.0.1.beta1 | app/models/my_forum/topic.rb |