LoginSignup
1
0

More than 3 years have passed since last update.

active_interaction での attributes の i18n

Posted at
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: パスワード
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0