On Tuesday, July 1, 2014 6:43:18 PM UTC+1, Chris Butcher wrote:
> Although, any help regarding validations would be much appreciated. I need 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 think you'll have to write a custom validation for this
validates :foo
def foo
# do whatever checks you want and call
# errors.add if the record isn't valid
end
I can never remember whether it is validate or validates.
Fred
--
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/e1771dff-4215-41aa-add9-5f18cb5fd4bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment