From 1431bef1a95a69fb200a059fcbad9fc7cfa25c4b Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Fri, 26 Apr 2013 08:46:06 -0500 Subject: [PATCH] Use first_or_create to creating missing Tags --- app/controllers/todos_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 4a70ccac..90384c02 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -724,8 +724,7 @@ class TodosController < ApplicationController @source_view = params['_source_view'] || 'tag' @tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability! @page_title = t('todos.all_completed_tagged_page_title', :tag_name => @tag_name) - @tag = Tag.where(:name => @tag_name).first - @tag = Tag.new(:name => @tag_name) if @tag.nil? + @tag = Tag.where(:name => @tag_name).first_or_create end