diff --git a/app/models/list.rb b/app/models/list.rb index d87c3cb..4867eb0 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -13,11 +13,15 @@ def initialize(name, id) List.new('ruby-talk', 4), ] - def self.find_by_name(name) - LISTS.find { |list| list.name == name } - end + class << self + def find_by_name(name) + List::LISTS.find { |list| list.name == name } + end + + def find_by_id(id) + List::LISTS.find { |list| list.id == id } + end - def self.find_by_id(id) - LISTS.find { |list| list.id == id } + alias find find_by_id end end diff --git a/app/models/message.rb b/app/models/message.rb index e08aa58..2896db4 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -127,7 +127,7 @@ def from_string(str) end def list - @list ||= List.find_by_id(list_id) + @list ||= List.find(list_id) end def count_recursively(count = 0) @@ -135,7 +135,7 @@ def count_recursively(count = 0) end def reload_from_s3(s3_client = Aws::S3::Client.new(region: BLADE_BUCKET_REGION)) - m = Message.from_s3(List.find_by_id(self.list_id).name, self.list_seq, s3_client) + m = Message.from_s3(List.find(self.list_id).name, self.list_seq, s3_client) self.body = m.body self.subject = m.subject diff --git a/app/views/messages/search.html.erb b/app/views/messages/search.html.erb index 45c2825..9ab4143 100644 --- a/app/views/messages/search.html.erb +++ b/app/views/messages/search.html.erb @@ -27,7 +27,7 @@ <% @messages.each do |message| %>