class Post

`counter_cache` requires association class before `attr_readonly`.

Public Class Methods

log(message = nil, side = nil, new_record = nil) click to toggle source
# File activerecord/test/models/post.rb, line 178
def self.log(message = nil, side = nil, new_record = nil)
  return @log if message.nil?
  @log << [message, side, new_record]
end
reset_log() click to toggle source
# File activerecord/test/models/post.rb, line 174
def self.reset_log
  @log = []
end
top(limit) click to toggle source
# File activerecord/test/models/post.rb, line 166
def self.top(limit)
  ranked_by_comments.limit_by(limit)
end
written_by(author) click to toggle source
# File activerecord/test/models/post.rb, line 170
def self.written_by(author)
  where(id: author.posts.pluck(:id))
end

Public Instance Methods

add_joins_and_select() click to toggle source
# File activerecord/test/models/post.rb, line 102
def add_joins_and_select
  select("tags.*, authors.id as author_id")
    .joins("left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id")
    .to_a
end
find_most_recent() click to toggle source
# File activerecord/test/models/post.rb, line 54
def find_most_recent
  order("id DESC").first
end
first_comment() click to toggle source
Calls superclass method
# File activerecord/test/models/post.rb, line 35
def first_comment
  super.body
end
greeting() click to toggle source
# File activerecord/test/models/post.rb, line 72
def greeting
  "hello"
end
newest() click to toggle source
# File activerecord/test/models/post.rb, line 58
def newest
  created.last
end
the_association() click to toggle source
# File activerecord/test/models/post.rb, line 62
def the_association
  proxy_association
end
with_content(content) click to toggle source
# File activerecord/test/models/post.rb, line 66
def with_content(content)
  self.detect { |comment| comment.body == content }
end