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

prepend_child throws an exception in case of invalid object #249

Closed
amitsaxena opened this issue Feb 3, 2017 · 1 comment
Closed

prepend_child throws an exception in case of invalid object #249

amitsaxena opened this issue Feb 3, 2017 · 1 comment

Comments

@amitsaxena
Copy link

amitsaxena commented Feb 3, 2017

prepend_child works fine if I try to save a valid item, but it throws an exception in case of validation errors. The behaviour should be similar to that of append_child which returns the object along with validation errors when someone tries to add a child. See below:

root = List.find(10)
child = List.new(:name => "test_bug")
child.valid?
=> false
root.prepend_child(child)
=> ActiveRecord::RecordNotFound: Couldn't find List without an ID
root.append_child(child)
=> #<List id: nil, ....>
child.valid?
=> false
child.errors
=>  #<ActiveModel::Errors:0x007f9c7a2add70...
@mceachen
Copy link
Collaborator

Thanks for the PR! Merged into v6.3.0

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

No branches or pull requests

2 participants