Is it possible in Rails 7 to localize the attributes in a form object including ActiveModel::Model
?
I have the following
class ProductionDataForm
include ActiveModel::Model
attr_accessor :monitorable_type
validates :monitorable_type, presence: true
end
And when monitorable_type
is missing, I’d like to display Post can't be blank
instead of Monitorable type can't be blank
.
So, as I do for objects inheriting from ApplicationRecord
, I tried to define
en:
activerecord:
attributes:
production_data_form:
monitorable_type: "post"
But is not working.
class ProductionDataForm
include ActiveModel::Model
include ActiveModel::Attributes
attribute :monitorable_type, :string # ?
validates :monitorable_type, presence: true
end
en:
activemodel:
attributes:
production_data_form:
monitorable_type: "post"