Code Monkey home page Code Monkey logo

Comments (7)

thetron avatar thetron commented on September 27, 2024

Could you also run bundle list and confirm that Mongoid is version 3.0.14, and Mongoid Token is version 1.1.0?

This might sound like a silly suggestion - but also just confirming that you restarted your rails server after installing mongoid_token?

from mongoid_token.

omidify avatar omidify commented on September 27, 2024

Confirmed the versions. It looks like the restart might have done it bc now I'm getting a routing error. Token is appearing in my model's hash, but as nil.

from mongoid_token.

thetron avatar thetron commented on September 27, 2024

In order to prevent token collisions, you need to make sure you've created your indexes with:

$ bundle exec rake db:mongoid:create_indexes

(I've just noticed this is missing from the mongoid token docs)

Also, you'll need to re-save any models that were created before mongoid_token was running, and it will generate tokens for those models.

from mongoid_token.

omidify avatar omidify commented on September 27, 2024

I've run the rake. Could you clarify what you mean by re-save models? Are you say drop users (in my case) and recreate the records? Resave the model user.rb file? Thanks.

from mongoid_token.

thetron avatar thetron commented on September 27, 2024

Sorry Omid, I meant that you need to re-save each database record that now has Mongoid::Token included. You could use the rails console to do this in one hit:

$ rails console
1.9.3-p0 :001 > User.all.each { | user | user.save }
1.9.3-p0 :002 > User.first
 => #<User _id: 50b3f7c0cbf60800a4000002, token: "9cmebuvgM3sH">

from mongoid_token.

thetron avatar thetron commented on September 27, 2024

I've closed this issue - but feel free to reopen it if you're continuing to have troubles.

from mongoid_token.

irfanfadilah avatar irfanfadilah commented on September 27, 2024

I got NameError: uninitialized constant Mongoid::Token::Collisions::Moped out of nowhere, it's happened when I tried to create new object..

Tried your suggestion to run the rake command and resave the model but the error still persist..

from mongoid_token.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.