def create
user = Users::Create.run(params.fetch(:user, {}))
if user.valid?
...
else
render json: { message: user.errors.full_messages.to_sentence }, status: :unprocessable_entity
end
end
Users::Create
という ActiveInteraction::Base
継承したクラスを定義している場合、以下のように書くと attributes を翻訳できます。
config/locals/interactions/user.yml
ja:
active_interaction:
attributes:
users/create: # Users::Create と合わせる
email: メールアドレス
password: パスワード