Simplify the method and fix Rubocop warnings

This commit is contained in:
Pierre Mesure
2020-03-30 21:40:10 +02:00
parent 055ff803c6
commit 67911b4e35
2 changed files with 3 additions and 9 deletions

View File

@@ -9,13 +9,8 @@ class Admin::TagsController < Admin::BaseController
end
def create
@existing_tag = Tag.where(name: tag_params.first).first
if @existing_tag
@existing_tag.kind = "category"
@existing_tag.save
else
Tag.category.create(tag_params)
end
Tag.find_or_create_by!(name: tag_params["name"]).update!(kind: "category")
redirect_to admin_tags_path
end