Git Product home page Git Product logo

Comments (17)

tute avatar tute commented on August 21, 2024

Thanks for reporting, @potomak. But doesn't this error make sense, since Merit is assuming AR in https://github.com/tute/merit/blob/master/lib/merit.rb#L15 if not stated otherwise? What should be a better behavior / error handling?

from merit.

tute avatar tute commented on August 21, 2024

Sorry now I see, it's the second step of the installation process. We should be listening for a --orm flag on that same command which presets the initializer correctly.

from merit.

potomak avatar potomak commented on August 21, 2024

I agree about the --orm flag or maybe you can change https://github.com/tute/merit/blob/master/lib/merit.rb#L15 to something like this

@@orm = Object.const_defined?('ActiveRecord') ? :active_record : :mongoid

Anyway I can't test solutions like this because test cases load both ActiveRecord and Mongoid.

from merit.

tute avatar tute commented on August 21, 2024

Tests should have isolated Gemfiles.

About --orm flag, I started testing the option but it places :mongoid as default value (couldn't get it right yet). Changes are in https://github.com/tute/merit/tree/generator_orm When we fix the default value I'll add it to master so installation works well for both ORMs.

Could you please show me a Gemfile for an only mongoid project?

Thanks!

from merit.

potomak avatar potomak commented on August 21, 2024

Here's the Gemfile of Tomatoes, the app where I'm using Merit (an only mongoid project): https://github.com/potomak/tomatoes/blob/develop/Gemfile

from merit.

tute avatar tute commented on August 21, 2024

I am not able to continue the Mongoid thing, as I am not a user of it and don't yet know how to test it. Code is still there though, but I'll only take responsability for ActiveRecord for now, until I learn or someone starts commiting there! :-)
Thanks for your report and commits!

from merit.

tute avatar tute commented on August 21, 2024

Renaming issue to "Mongoid support", and leaving it open as a feature request.

from merit.

sairamc avatar sairamc commented on August 21, 2024

Any update on this? Would this gem work with mongoid?

from merit.

tute avatar tute commented on August 21, 2024

I can't provide this because I don't use mongoid or mongomapper, and we don't have good tests coverage yet. There's code in there but I couldn't maintain it. A recent fork improved it, may be working: https://github.com/jruizes/merit (check it's latest commits).

from merit.

sairamc avatar sairamc commented on August 21, 2024

Thanks for the pointer. There is a known issue with your branch when using Rails 3.2.8 with Mongoid 3.1. When I include the gem and try to start the server I get:
/.rvm/gems/ruby-1.9.3-p125/gems/merit-1.0.1/lib/merit/models/active_record/sash.rb:1:in `<top (required)>': uninitialized constant ActiveRecord (NameError)

I got around the issue by using jruizes's fork.
gem 'merit', :git => "git://github.com/jruizes/merit.git"

But there is still an issue with the fork creating the right models for mongo documents. I'll try to fork and play with the branch.

from merit.

tute avatar tute commented on August 21, 2024

Yes, thanks @sairamc. Maybe you'll get it running nicely and many will be grateful for that, but without extensive tests I won't be able to keep it running. So if you can add good test for this functionality, I'll merge it into merit and take it out of "experimental".
Best!

from merit.

tute avatar tute commented on August 21, 2024

Closing this issue, as I will not be able to maintain it. Unless someone wants to take care of it, and I'll gladly add him/her as a contributor! :-)

from merit.

bshyong avatar bshyong commented on August 21, 2024

Hey @tute is this gem working with mongoid now? I saw some commits regarding mongoid and I've been trying for some time now to get this to work, but I can't seem to run the generators. Here's my stack trace:

/gems/merit-1.3.1/lib/merit/models/active_record/sash.rb:7:in <top (required)>': uninitialized constant ActiveRecord (NameError) /gems/merit-1.3.1/lib/merit.rb:45:inblock in class:Engine'

I also tried modifying the file to use :mongoid as the orm, but it still tries to use ActiveRecord for some reason. Any thing I'm missing here?

Thanks a lot for working on this gem!

from merit.

tute avatar tute commented on August 21, 2024

Hi! Indeed, there is code for making it work, but it went stale, as I don't use/know enough Monoig/MongoMapper. That said, there's relevant code/file structure for you to work on, it shouldn't be hard to get it in shape. The only thing you have to know is that we shouldn't use ActiveRecord wherever without checking Merit.orm option, and that there's models for each ORM in lib/merit/models.
Thanks for your feedback!

from merit.

jeremylynch avatar jeremylynch commented on August 21, 2024

Can we please reopen this issue? It is time that mongoid support for this app is fully implemented and sorted out.

These are the steps I tried to get merit working on a mongoid app:

1. Add Merit to gemfile and run bundle install

gem 'merit', :git => "https://github.com/tute/merit.git" # version 1.70 approximately

2. Create Merit Badges

$ Merit::Badge.create!({ id: 3, name: 'just-registered' })
=> #<Merit::Badge id: 3, name: "just-registered", level: nil, image: nil, description: nil, custom_fields: nil>

3. Configure Merit initializer in config/initializers/merit.rb

Merit.setup do |config|
  config.orm = :mongoid
end

4. Copy badge_rules.rb, point_rules.rb and rank_rules.rb from templates in lib/generators to models/merit

5. Restart rails server and rails console

6. Attempt to manually add badge to a user

$ @user = User.last
$ @user.add_badge(3)
=> NoMethodError: undefined method `add_badge' for #<User:0x007fa95ecc6398>
$ @user.badges
=> NoMethodError: undefined method `badges' for #<User:0x007fa960515a48>

from merit.

jeremylynch avatar jeremylynch commented on August 21, 2024

Has anybody successfully gotten recent versions of Merit to work with mongoid?

from merit.

jeremylynch avatar jeremylynch commented on August 21, 2024

#123

from merit.

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.