Sha256: 22d8841c3385f4122a072f22d0aa99400b165b79c43d4bc33d90bd699f7bba15

Contents?: true

Size: 687 Bytes

Versions: 10

Compression:

Stored size: 687 Bytes

Contents

module  Crowdblog
  class User < ActiveRecord::Base
    self.table_name = :users
    include Gravtastic

    has_many :authored_posts, inverse_of: :author, foreign_key: 'author_id', class_name: 'Post'
    has_one  :last_post, class_name: 'Post', foreign_key: :author_id, conditions: ['state = ?', 'published'], order: 'published_at DESC, created_at DESC, id DESC'

    gravtastic :gravatar_email


    # INSTANCE METHODS
    def gravatar_email
      gravatar_alias || email
    end

    def last_post_at
      last_post.try(:published_at)
    end

    def publisher!
      update_attribute(:is_publisher, true)
    end

    def to_param
      [email.split('@').first]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
crowdblog-0.0.16 app/models/crowdblog/user.rb
crowdblog-0.0.15 app/models/crowdblog/user.rb
crowdblog-0.0.14 app/models/crowdblog/user.rb
crowdblog-0.0.13 app/models/crowdblog/user.rb
crowdblog-0.0.12 app/models/crowdblog/user.rb
crowdblog-0.0.10 app/models/crowdblog/user.rb
crowdblog-0.0.9 app/models/crowdblog/user.rb
crowdblog-0.0.8 app/models/crowdblog/user.rb
crowdblog-0.0.7 app/models/crowdblog/user.rb
crowdblog-0.0.6 app/models/crowdblog/user.rb