お世話になります。
今回、新たにService層の導入を考えており、ディレクトリ構造を考えております。
まずは動くものをと思い、定義したService層のメソッドをコントローラーから呼ぼうとしたのですが、以下エラーとなってしまい教えていただきたいと思います...
エラー文
NameError (uninitialized constant CustomerUpdate): app/controllers/customers_controller.rb:23:in 'update'
コントローラー
customers_controller.rb
ruby
1class CustomersController < ApplicationController 2 def show 3 ~ 4 customer = Customer.find(1) 5 ::CustomerUpdate::UpdateCusotmer.new(customer).call 6 ~ 7 end 8end
Service層
app/services/customer/customer_update.rb
ruby
1module CustomerUpdate 2 class UpdateCustomer 3 def initialize(customer) 4 @customer = customer 5 end 6 7 def call 8 customer.update!(email: 'sample@test') 9 end 10 end 11end
色々名前を変えて試しているのですが、こちらのエラーが解消できず、Service層にアクセスできない状態です。
上記の他に設定する必要がある箇所などあれば教えていただきたいと思います。
よろしくおねがいいたします。

回答1件
あなたの回答
tips
プレビュー