search_handlers_controller.rb
class SearchHandlersController < ApplicationController
def match
@string = 'string'
@result = case params['search_style']
when 'match'
MatchService.call(@string)
...
/services 中的 MatchService.rb:
# frozen_string_literal: true
class MatchService < ApplicationService
...
def call(string)
'Match'
end
end
从 SearchHandlersController#match 调用 MatchService 时出错:
NameError (uninitialized constant SearchHandlersController::MatchService):
app/controllers/search_handlers_controller.rb:18:in `match'