This commit is contained in:
2026-01-29 22:46:21 +09:00
parent a4ec7b44c7
commit 29d339595c
3 changed files with 20 additions and 4 deletions
@@ -11,4 +11,15 @@ class ApplicationController < ActionController::API
code = request.headers['X-Transfer-Code'] || request.headers['HTTP_X_TRANSFER_CODE']
@current_user = User.find_by(inheritance_code: code)
end
def bool? key, default: false
return default if params[key].nil?
s = params[key].to_s.strip.downcase
if default
!(s.in?(['0', 'false', 'off', 'no']))
else
s.in?(['', '1', 'true', 'on', 'yes'])
end
end
end
+3 -3
View File
@@ -16,8 +16,8 @@ class TagsController < ApplicationController
q = params[:q].to_s.strip
return render json: [] if q.blank?
with_nico = !(params[:nico].to_s.strip.downcase.in?(['0', 'false', 'off', 'no']))
with_empty = params[:empty].to_s.strip.downcase.in?(['1', 'true', 'on', 'yes'])
with_nico = bool?(:nico, default: true)
present_only = bool?(:present, default: true)
alias_rows =
TagName
@@ -34,7 +34,7 @@ class TagsController < ApplicationController
end
base = Tag.joins(:tag_name).includes(:tag_name)
base = base.where('tags.post_count > 0') unless with_empty
base = base.where('tags.post_count > 0') if present_only
canonical_hit =
base