Reputation: 13
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
Upvotes: 0
Views: 82
Reputation: 13
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
Upvotes: 0