Comments (11)
Thanks for the report, you are doing things right, it's a bug! Working on it right now.
from merit.
@starmandell, you should upgrade to 0.6.1, and include the following lines in app/models/merit/* files, just after the class definition, before the 'initialize' method:
include Merit::BadgeRulesMethods # in app/models/merit/badges_rules.rb
include Merit::PointRulesMethods # in app/models/merit/point_rules.rb
include Merit::RankRulesMethods # in app/models/merit/rank_rules.rb
It was a namespace issue, thanks again for reporting!
If you think we could improve documentation, I'm eager to help, just tell me how.
from merit.
thanks for fixing that = )
i had another question, this might be specific to my app but i get the following error now
Can't mass-assign protected attributes: user_id, action_method, action_value, had_errors, target_model, target_id
do i need to make it explicit in my User model for the mentioned above to be attr_accessible? and if so, isn't making :user_id attr_accessible unsafe? in my User model as well, does the line of the code
has_merit
essentially replace the need to write stuff like... has_many: merits? because instead of mass assignment, i tried instead to do something like..
@lesson.action_method = params[:lesson][:action_method]
but it cant seem to find the method
thanks again = )
from merit.
Regarding whitelisting attributes, just did it, please use 0.6.2. Thanks for reporting!
Those attributes belong to the MeritAction table, which merit uses to check if defined rules apply. So @lesson.action_method
wouldn't work (if you want to play with it, MeritAction.where(target_id: @lesson.id)
may work). has_merit
adds class and instance methods to models, but they shouldn't be needed in the app. I can explain them if you want to dig into the internals though!
Regards.
from merit.
thanks for fixing it!
i got the tables to fill with some data.
i had some questions though. i hope you don't mind me asking. hopefully my requests have been helpful to you guys somewhat = )
would you mind clarifying in your documentation what exactly the migration tables are meant for? and also...
do we have to create a separate Badge table? to use functions like
Badge.find(3).grant_to(current_user)
if not, when we define rules like
grant_on 'lessons#create', :badge => 'lesson-stronghold', :to => :user do |lesson|
lesson.user.lessons.count == 2
end
i was curious where the badge name gets stored. maybe an example of how to retrieve the users badges would be helpful as well?
thanks for the help = ) hopefully my reports have been somewhat helpful haha = )
from merit.
Hi! For a quick answer, badges are stored in a Ruby file, in config/initializers/merit.rb
. You will see a Badge example, and there's a URL for ambry gem which is the library we are using to store/retrieve them.
I now have in mind how can we start documenting Merit: it was hard for me to think with a clean state of mind and help with documentation. So thanks for your comments, they help indeed!
from merit.
oh cool!
thanks! i look forward to the documentation.
thanks for being responsive and caring about user input = )
from merit.
hmmm maybe you can also white list these? after creating a badge in the merit.rb file and restarting the server and trying to execute
grant_on 'lessons#create', :badge => 'lesson-stronghold', :to => :user do |lesson|
lesson.user.lessons.count == 5
end
i come across
Can't mass-assign protected attributes: sash_id, badge_id
'lesson-stronghold' was the badge i created in the merit.rb file. and then if i edit back badge_rules.rb, and change the name of the badge to something else (that doesn't currently exist),
i get the error
undefined method `grant_to' for nil:NilClass
when trying to access the lessons#create action.
just reporting = )
from merit.
Nice, so, two things:
- sash_id and badge_id are in your "meritable" model, Lesson in this case, so you may white liste them from ther for now. I won't white list them because anyone could grab anybody's reputation, but I'll update those attributes without #update_attributes so we have control. I'll tell you when you can black list them again!
- I'll add an error handler for inexistent badges.
We'll make this better and better! :-)
from merit.
hmmm i must be doing something wrong but i cant seem to get past the error above of mass-assigning attributes.
in my Lesson model, i have...
attr_accessible :title, :desc, :content, :tag_names, :sash_id, :badge_id
am i supposed to be doing something else as well?
and most definitely i wish merit to be well = )
from merit.
Fixed in v0.6.3, thanks for reporting! Merit is doing better. :-)
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.