Comments (17)
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.
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.
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.
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.
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.
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.
Renaming issue to "Mongoid support", and leaving it open as a feature request.
from merit.
Any update on this? Would this gem work with mongoid?
from merit.
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.
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.
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.
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.
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:in
block 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.
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.
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.
Has anybody successfully gotten recent versions of Merit to work with mongoid?
from merit.
from merit.
Related Issues (20)
- undefined method 'create' for Merit:Action:Class HOT 12
- Use DeviseInvitable with Merit HOT 2
- Display flash messages to notify users when they obtain badges/points HOT 9
- Adding points doesn't work the first time HOT 1
- Display a specific badge and the users who obtained it HOT 2
- Merit 4.0 causing Heroku deployment errors HOT 4
- Typo in active_record/merit_generator task
- Deprecation warning: Expected string default value for '--orm'; got false (boolean). HOT 3
- Granting badges with Devise Registrations#update not working HOT 11
- rails g merit:install don't generating migrations on Rails6 HOT 18
- can't write unknown attribute `sash_id` when calling points method on user HOT 3
- subtract_points is not working HOT 3
- Missing index on merit_actions table for processed HOT 2
- Error on create merit_actions migration file HOT 2
- Score on namespaced/controller#action, can not trigger Merit::Action HOT 6
- Error every time code changes HOT 7
- do not support grape? HOT 1
- Devise & Sign-in then trigger grant_on HOT 12
- On destroy, Integer returned instead of object HOT 11
- Urgent Help : Duplicate key entry HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from merit.