Say Item has_many Images. item = Item.new(stuff) image = Image.new(bad_stuff) item.image = image item.save I don''t want item.save to work if the image is not working right for whatever reason. How does that work? Would I use validates_associated :image in Item? And then create Image#validate? Thanks, Joe
Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:> Say Item has_many Images. > > item = Item.new(stuff) > image = Image.new(bad_stuff) > item.image = image > item.save > > I don''t want item.save to work if the image is not working right for > whatever reason. How does that work? Would I use > validates_associated :image in Item? And then create > Image#validate?Remember that all the validates_* methods really just append to the default Image#validate. Every AR object has a validate method, even if it just inherits one from AR. -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org