aboutsummaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-11 22:45:05 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-11 22:51:23 +0100
commitc0befbd02559591b0c2871ea9cef1e4d913b9ef6 (patch)
tree60c6a6fbc2f7145499ee9cbe0ab3ad6f7cf73b64 /app/controllers
parent2a4fedb96791cd80bd6092a0b508f265e4d35348 (diff)
downloadoperum-c0befbd02559591b0c2871ea9cef1e4d913b9ef6.tar.gz
operum-c0befbd02559591b0c2871ea9cef1e4d913b9ef6.zip
Allow searching from a given tag
This feature is useful if you want to have a quick search on how many resources apply for a single tag. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/tags_controller.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index ee837ef..c5ca6a8 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[edit update destroy]
+ before_action :set_tag, only: %i[edit update destroy search]
def index
@tags = Tag.order(:name)
@@ -57,10 +57,16 @@ class TagsController < ApplicationController
redirect_to tags_url, notice: t('tags.destroy-success')
end
+ def search
+ @search = Search.new(name: 'temporary', body: "tag:\"#{@tag.name}\"")
+
+ render 'searches/show'
+ end
+
private
def set_tag
- @tag = Tag.find(params[:id])
+ @tag = Tag.find(params[:id] || params[:tag_id])
end
def tag_params