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

MongoMapper - can't modify frozen object on destroy #9

Closed
motdotla opened this issue Aug 30, 2009 · 3 comments
Closed

MongoMapper - can't modify frozen object on destroy #9

motdotla opened this issue Aug 30, 2009 · 3 comments

Comments

@motdotla
Copy link
Contributor

Jonas, great upload gem. I really like it - was super easy to get started with. Thank you.

I am getting one error related to using it with mongomapper, but I realize you just added this support.

The error is 'Type error: can't modify frozen object' when doing User.destroy_all or User.first.destroy, etc. The error is only on destroy and the user actually gets destroyed, but tests fail because of the ugly error.

Following is the stacktrace with the rspec test I'm running. I had the same issues when running in merb -i -e test|development

http://gist.github.com/177890

I do not get the same error if I delete by doing: User.delete(@u.id) or User.delete_all

Possibly, it's related to MongoMapper's destroy method in lib/document.rb lines 302-308?:
def destroy
return false if frozen?

    criteria = FinderOptions.to_mongo_criteria(:_id => id)
    collection.remove(criteria) unless new?
    freeze
  end
@jnicklas
Copy link
Member

Sorry about that, MongoMapper support is still a bit experimental.

I can't seem to replicate this error, could you try writing a failing spec?

@motdotla
Copy link
Contributor Author

Ok, I've forked and updated with the failing test. It's at:

http://github.com/scottmotte/carrierwave/tree/master

I'll send a pull request too.

@jnicklas
Copy link
Member

Don't memoize in frozen objects. Closed by fca5eb2

This issue was closed.
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