Slava Tkachenko
Slava Tkachenko

Reputation: 13

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

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

Answers (1)

Slava Tkachenko
Slava Tkachenko

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

Related Questions