johnelahr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2014-Apr-24 19:50 UTC
Validation of model object through a relationship
I'm a beginner in Rails working through the Hartl tutorial while trying to work on my own project(s) at the same time. One Project I'm trying to work on is a basic 'assembly' application because it's what I do now full time. Right now it's a pretty basic app with 3 Models Ingredient Bulk RecipeItem There is a has_many through relationship between Ingredient and Bulk through RecipeItem In the recipe_items table there is an additional attribute i'm calling quantity - it must be greater than 0 and less than 1. The validation question I have is this. Is there an easy way to set up a validation on a Bulk object that requires its related RecipeItem objects to add up to one...after all the recipeitem objects are added? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f16095c4-da9e-44bd-a094-f9539a99885c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.