We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
destroy or destroy all on embedded documents doesnt destroy all object.
person.rb
class Person embeds_many :pictures, :cascading_callback => true end
picture.rb
class Picture embedded_in Person
has_mongoid_attached_file :picture end
in PersonsController
def delete_pictures
if @person.pictures.present? @person.pictures.destroy_all end
end
If beforehand the person database have pictures, this WON'T WORK Properly, somehow. Destroy doesnt delete all of my picture objects.
Even with
@person.pictures.each do |p| p.destroy end
Doesnt do the trick.
My own hack is to use this:
Controller while @person.pictures.present?
@person.pictures.each do |p| @person.pictures.destroy end end
Can somebody explain to me what did i do wrong?
Thanks!
The text was updated successfully, but these errors were encountered:
+1
Sorry, something went wrong.
No branches or pull requests
destroy or destroy all on embedded documents doesnt destroy all object.
person.rb
class Person
embeds_many :pictures, :cascading_callback => true
end
picture.rb
class Picture
embedded_in Person
has_mongoid_attached_file :picture
end
in PersonsController
def delete_pictures
if @person.pictures.present?
@person.pictures.destroy_all
end
end
If beforehand the person database have pictures, this WON'T WORK Properly, somehow. Destroy doesnt delete all of my picture objects.
Even with
@person.pictures.each do |p|
p.destroy
end
Doesnt do the trick.
My own hack is to use this:
Controller
while @person.pictures.present?
@person.pictures.destroy_all doesnt work either, coz after that the pictures array is empty, when on next reload not.
@person.pictures.each do |p|
@person.pictures.destroy
end
end
Can somebody explain to me what did i do wrong?
Thanks!
The text was updated successfully, but these errors were encountered: