Sha256: b0a5f2699d54a28e4761c14ab40602738dbcd0c3f2a24b34fd3b8edb4943e181
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module AuxiliaryRails module ViewHelpers module HumanNameHelper # Human-readable name for a model or a model's attribute # # @param model [Class, Object] The model class or an instance of the model # @param attribute [Symbol, String, nil] The attribute name (optional) # @return [String] The human-readable name def human_name(model, attribute = nil, count: 1) if attribute.nil? model.model_name.human(count: count) else model = model.class unless model.is_a?(Class) if count > 1 model.human_attribute_name(attribute).pluralize(count) else model.human_attribute_name(attribute) end end end # Human-readable name for a model or a model's attribute plural form # # @param model [Class, Object] The model class or an instance of the model # @param attribute [Symbol, String, nil] The attribute name (optional) # @return [String] The human-readable name in plural form def human_name_plural(model, attribute = nil, count: 2) human_name(model, attribute, count: count) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
auxiliary_rails_resourceable-0.1.3 | lib/auxiliary_rails/view_helpers/human_name_helper.rb |
auxiliary_rails_resourceable-0.1.2 | lib/auxiliary_rails/view_helpers/human_name_helper.rb |