Hi,

the validator of the LineItem model throws an error message with
errors.add(:quantity,
I18n.t('validation.cannot_be_greater_than_available_stock'))

The ActiveModel processes errors with full_messages method:
def full_messages
map { |attribute, message| full_message(attribute, message) }
end

def full_message(attribute, message)
return message if attribute == :base
attr_name = attribute.to_s.gsub('.', '_').humanize
attr_name = @base.class.human_attribute_name(attribute, :default =>
attr_name)
I18n.t(:"errors.format", {
:default => "%{attribute} %{message}",
:attribute => attr_name,
:message => message
})
end

The 'message' part is simply translated with
"validation.cannot_be_greater_than_available_stock" key in YAML file.
The question is how can I translate the attribute part ? In cart's view it
contains passed :quantity prepended with "Line items" so attribute ~ "Line
items quantity".

Any idea ?

Thanks.

David




--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/kIqzKaocd_AJ.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedDec 13, '12 at 6:35p
activeDec 13, '12 at 6:35p
posts1
users1
websitespreecommerce.com
irc#RubyOnRails

1 user in discussion

David Unric: 1 post

People

Translate

site design / logo © 2022 Grokbase