Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an invalid record to an association does not raise an error #286

Open
IdahoEv opened this issue Apr 11, 2012 · 0 comments
Open

Adding an invalid record to an association does not raise an error #286

IdahoEv opened this issue Apr 11, 2012 · 0 comments

Comments

@IdahoEv
Copy link
Contributor

IdahoEv commented Apr 11, 2012

When you add an invalid record to a linked 'many' association, it fails to save the record, but adds it to the array anyway without raising an error. Having the unsaved record in the array can then trigger a different issue (riak-ruby-client issue #32 basho/riak-ruby-client#32) when you try to save the outer record.

This snippet reproduces the issue in 798b898:

    class InnerDoc
       include Ripple::Document
       property :foo, String
       validates_presence_of :foo
    end
    class OuterDoc
       include Ripple::Document
       many :inner_docs
    end
    o_d = OuterDoc.new
    i_d = InnerDoc.new(:foo => nil)
    o_d.inner_docs << i_d       

No exception is raised, but after the above code is run, the following are true:

i_d.valid? == false
o_d.inner_docs == [ i_d ]
i_d.key == nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant