From ccf588845a6e595d1c9b2726a05eddd34bc92488 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 20 Mar 2024 13:59:15 +0100 Subject: tags: added a way to update tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's useful to just rename tags which have quite some references that you don't want to nuke. Signed-off-by: Miquel Sabaté Solà --- app/controllers/tags_controller.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 8ae36d7..9d87687 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class TagsController < ApplicationController - before_action :set_tag, only: %i[destroy] + before_action :set_tag, only: %i[edit update destroy] def index @tags = Tag.order(:name) @@ -11,6 +11,8 @@ class TagsController < ApplicationController @tag = Tag.new end + def edit; end + def create @tag = Tag.new(tag_params) @@ -21,6 +23,14 @@ class TagsController < ApplicationController end end + def update + if @tag.update(tag_params) + redirect_to tags_url, notice: t('tags.update-success') + else + render :edit, status: :unprocessable_entity + end + end + def destroy @tag.destroy! -- cgit v1.2.3