'Ruby on Rails I18n interpolation
everyone!
I have a small validation for my :username field, which should be from 4 to 30 characters. I wrote a validation: :length => { :within => 4..30, :message => I18n.t('activerecord.errors.range') - I wanted to display a single error message for all kinds of errors (Not like, too_long or too_short), but here's the question - can I pass both min and max values to the translation, to have something like: Username should be between 4 and 30 characters. Currently I have: range: "should be between %{count} and %{count} characters", which obviously doesn't work (made it just for checking).
Is it possible to grab these values from the range ?
Thanks everyone in advice!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
