How to break down decent-exposure code to classic Rails way?

80 views Asked by At

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

There are 1 answers

0
Slava Tkachenko On BEST ANSWER
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