Remove anemic concern

This commit is contained in:
David Heinemeier Hansson
2025-11-03 15:27:12 +01:00
parent 3116cea6a1
commit 9913853cc6
3 changed files with 4 additions and 18 deletions
@@ -1,12 +0,0 @@
module Search::QueryTermsScoped
extend ActiveSupport::Concern
included do
before_action :set_query_terms
end
private
def set_query_terms
@query_terms = params[:q]
end
end
@@ -1,8 +1,6 @@
class Searches::QueriesController < ApplicationController
include Search::QueryTermsScoped
def create
Current.user.remember_search(@query_terms)
Current.user.remember_search(params[:q])
head :ok
end
end
+3 -3
View File
@@ -1,8 +1,8 @@
class SearchesController < ApplicationController
include Search::QueryTermsScoped, Turbo::DriveHelper
include Turbo::DriveHelper
def show
if card = Current.user.accessible_cards.find_by_id(@query_terms)
if card = Current.user.accessible_cards.find_by_id(params[:q])
@card = card
else
perform_search
@@ -11,7 +11,7 @@ class SearchesController < ApplicationController
private
def perform_search
set_page_and_extract_portion_from Current.user.search(@query_terms)
set_page_and_extract_portion_from Current.user.search(params[:q])
@recent_search_queries = Current.user.search_queries.order(updated_at: :desc).limit(10)
end
end