On Tue, Jul 1, 2014 at 10:43 AM, Chris Butcher
<christopherbutcher@live.com> wrote:
> the user's entered value for the impact and likelihood fields to be an
> integer between 0 and 100. What I would usually expect would work, something
> like:
>
> validates_inclusion_of :impact, :in => 0..100
>
> doesn't. Validation always fails, presumably because the input is generated
> as an array with an integer inside, rather than a traditional integer.
> Anyone know how I could bypass this issue?
I really don't understand your use case of storing a single integer
as a single-element array, but perhaps just use e.g.
... :in => acceptable_range
def acceptable_range
(1..100).each.map{ |n| [n] }
end
FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBVZmkN9ks451Q5RMgon4tBsn8_Vh2iw2Xk%3DfWUQQWfTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.