0

Can anyone break this code down for me and explain how this can be done in classic Rails way with callbacks(if any) and methods?

class SearchController < ApplicationController
  expose :search_result, -> { SearchService.new(search_params).call }

  def search_params
    params.permit(:q, :scope)
  end
end

1 Answers1

0
class SearchController < ApplicationController
  def index
    @search_result = SearchService.new(search_params).call
  end

  def search_params
    params.permit(:q, :scope)
  end
end

expose :search_result, -> { SearchService.new(search_params).call } creates a variable @search_result