You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#human_attribute_name on class that inherited from ActiveModelSerializers::Model returns it's translation according to ActiveModel::Translation#human_attribute_name functionality.
Actual behaviour
#human_attribute_name on class that inherited from ActiveModelSerializers::Model returns an attribute passed to it without any translations.
Steps to reproduce
Create a poro and inherit it from ActiveModelSerializers::Model:
I found the method implementation in ActiveModelSerializers::Model, and I have a question. Why do we need this method defined within ActiveModelSerializers::Model when it's already supplied within ActiveModel?
The text was updated successfully, but these errors were encountered:
@eugen0329 Sounds like you understand the problem well enough to issue a pull request. Would you be interested in doing that? I don't see it included in ActiveModel::Model... oh, n/m it has extend ActiveModel::Translation
# # The following methods are needed to be minimally implemented
#
# def read_attribute_for_validation(attr)
# send(attr)
# end
#
# def self.human_attribute_name(attr, options = {})
# attr
# end
#
# def self.lookup_ancestors
# [self]
# end
# end
#
# The last three methods are required in your object for +Errors+ to be
# able to generate error messages correctly and also handle multiple
# languages. Of course, if you extend your object with <tt>ActiveModel::Translation</tt>
# you will not need to implement the last two. Likewise, using
# <tt>ActiveModel::Validations</tt> will handle the validation related methods
# for you.
As pointed out in
rails-api#2049
ActiveModel::Model already extends ActiveModel::Translation which
implements human_attribute_name and lookup_ancestors
As pointed out in
rails-api#2049
ActiveModel::Model already extends ActiveModel::Translation which
implements human_attribute_name and lookup_ancestors
Expected behavior vs actual behavior
#human_attribute_name
on class that inherited from ActiveModelSerializers::Model returns it's translation according to ActiveModel::Translation#human_attribute_name functionality.Actual behaviour
#human_attribute_name
on class that inherited from ActiveModelSerializers::Model returns an attribute passed to it without any translations.Steps to reproduce
Environment
active_model_serializers (~> 0.10.2)
Additonal helpful information
I found the method implementation in ActiveModelSerializers::Model, and I have a question. Why do we need this method defined within ActiveModelSerializers::Model when it's already supplied within ActiveModel?
The text was updated successfully, but these errors were encountered: