#1163 new
Sam Merritt

the "many" model from a many-to-one relationship can #save but isn't #valid?

Reported by Sam Merritt | December 21st, 2009 @ 05:25 PM

Full, runnable example here: http://gist.github.com/261185

If you have a many-to-one relationship, e.g. a sheep has many hooves, you can have a hoof model where hoof.valid? is false, but hoof.save is true.

That is,

s = Sheep.new
h = s.hooves.new

h.valid? # => false because :sheep_id is nil h.save # => true; the parent gets saved first, thereby making h valid

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket