From 41a470c4c021b9653c7983d7285a08622541ca0f Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 28 Sep 2011 14:38:17 +0200 Subject: [PATCH] issue #10 using any? is clearer --- models/post.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/models/post.rb b/models/post.rb index 907e346..040d6db 100644 --- a/models/post.rb +++ b/models/post.rb @@ -40,12 +40,8 @@ class Post # checks if a post has this tag def has_tag tag - tags.each do |t| - if t.id == tag.id - return true - end - end - false + tag_id = tag.id + tags.any? { |t| t.id == tag_id } end # sets all tags for this post