This project is archived and is in readonly mode.
Ensure that save on child object fails for invalid belongs_to - TAKE TWO
-
Ruy Asan
Apparently some people actually enjoy working with diffs ;)
-
Pratik
- State changed from new to incomplete
- Assigned user set to Pratik
First need to reproduce the old behavior :) I'm planning to add :validate => true/false option to association definition. So we can get this in after that is done.
-
Ruy Asan
Looks like => true/false is now done and already covers the meat of this ticket, although even after updating my tests with
belongs to =>trueI still can't get a failure.Patch with stubbornly passing tests attached.
-
Tony Ennis
- Tag set to activerecord, edge, patch, tested
I am not sure if this is the same thing or not, but symptoms of my problem are:
class A belongs_to B
a = instance of A
b = instance of B
create a
create b using 'a.the_belongs_to_column.create(yadda)'
a.save!
1. b's validation is being called
2. the validation is failing
3. the row is not written.
4. a.save! does not report an error.
5. a's row was written
-
Tony Ennis
Sorry previous tag is leftover from a web search. Tag should be ""
-
Alberto Perdomo
Hi,
Looking up the docs in api.rubyonrails.org it seems that there was a :validate key before that used to default to false. Example:
belongs_to :assocation, :validate => true
But trying to use it in rails 2.1.0 returns an invalid key error.
It seems that the validate key was removed. Why?
In my case i am using a create_assocation call, the parent object fails validation but the child object is saved...
-
Pratik
- State changed from incomplete to wontfix
This isn't needed anymore now that we have :validate option.
