Sha256: 0399255f27b96bd23c10d135bc4d643b0051765ea466843efcbb81c9e354671a
Contents?: true
Size: 738 Bytes
Versions: 4
Compression:
Stored size: 738 Bytes
Contents
module Crowdblog class User < ActiveRecord::Base has_many :authored_posts, inverse_of: :author, foreign_key: 'author_id', class_name: 'Post' has_many :published_posts, inverse_of: :author, foreign_key: 'author_id', class_name: 'Post', conditions: ['state = ?', 'published'], order: 'published_at DESC' has_one :last_post, class_name: 'Post', foreign_key: :author_id, conditions: ['state = ?', 'published'], order: 'published_at DESC, created_at DESC, id DESC' def is_publisher? true end def last_post_at last_post.try(:published_at) end def last_published_at published_posts.first ? published_posts.first.published_at : nil end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
crowdblog-0.3.3 | app/models/crowdblog/user.rb |
crowdblog-0.3.2 | app/models/crowdblog/user.rb |
crowdblog-0.3.1 | app/models/crowdblog/user.rb |
crowdblog-0.3.0 | app/models/crowdblog/user.rb |