From 108e7aec9f2e17aa39197545bb890a0e2e206b7e Mon Sep 17 00:00:00 2001 From: Noah Portes Chaikin Date: Tue, 14 Jan 2014 11:15:35 -0500 Subject: [PATCH] Delegate :username rather than using a class method. This is just a little cleaner? --- app/models/post.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index e8d336980c3..e852cb9ed03 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -51,7 +51,9 @@ class Post < ActiveRecord::Base scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) } scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) } scope :with_topic_subtype, ->(subtype) { joins(:topic).where('topics.subtype = ?', subtype) } - + + delegate :username, to: :user + def self.hidden_reasons @hidden_reasons ||= Enum.new(:flag_threshold_reached, :flag_threshold_reached_again, :new_user_spam_threshold_reached) end @@ -206,10 +208,6 @@ class Post < ActiveRecord::Base cooked end - def username - user.username - end - def external_id "#{topic_id}/#{post_number}" end