class Object

Public Instance Methods

downcase_and_pluralize(input) click to toggle source
# File lib/at_most.rb, line 4
def downcase_and_pluralize(input)
  return "#{ input.to_s.downcase }s"
end
i18n_error(model) click to toggle source
# File lib/at_most.rb, line 12
def i18n_error(model)
  if !I18n.t("activerecord.errors.models.#{ downcase_and_pluralize(model.class) }.at_most").include?("missing")
    I18n.t("activerecord.errors.models.#{ downcase_and_pluralize(model.class) }.at_most")
  elsif !I18n.t("at_most").include?("missing")
    I18n.t("at_most")
  end
end
validation_error(model, message) click to toggle source
# File lib/at_most.rb, line 8
def validation_error(model, message)
  message || i18n_error(model) || "Maximum number of #{model.class}s has been reached"
end