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

including Mongoid::Paranoia changes the update method from public to private #39

Closed
maxjacobson opened this issue Sep 25, 2015 · 2 comments · Fixed by #40
Closed

including Mongoid::Paranoia changes the update method from public to private #39

maxjacobson opened this issue Sep 25, 2015 · 2 comments · Fixed by #40
Assignees
Labels

Comments

@maxjacobson
Copy link

class Human
  include Mongoid::Document
end
human = Human.create #=> #<Human _id: 5605a9a71942d01471000002, >
human.update #=> true
Mongoid::Compatibility::Version.mongoid5? #=> true
class Robot
  include Mongoid::Document
  include Mongoid::Paranoia
end
robot = Robot.create #=> #<Robot _id: 5605a9d11942d01471000003, deleted_at(deleted_at): nil>
robot.update
# NoMethodError: private method `update' called for #<Robot:0x00000103c2ecd8>

The update method: https://github.com/mongodb/mongoid/blob/ffad088b8c75390d01424494f17eb25ac285db90/lib/mongoid/persistable/updatable.rb#L40-L54

@simi
Copy link
Owner

simi commented Sep 28, 2015

@dblock this is related to

# Update value in the collection.
#
# @return [ Object ] Update result.
def update(value)
query = paranoid_collection.find(atomic_selector)
if Mongoid::Compatibility::Version.mongoid5?
query.update_one(value)
else
query.update(value)
end
end
end
. Should we use better name for that method like _paranoia_update or similar?

@simi simi self-assigned this Sep 28, 2015
@simi simi added the bug label Sep 28, 2015
@dblock
Copy link
Contributor

dblock commented Sep 28, 2015

@simi Sounds like it!

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

Successfully merging a pull request may close this issue.

3 participants