Git Product home page Git Product logo

Comments (11)

tute avatar tute commented on August 21, 2024

Thanks for the report, you are doing things right, it's a bug! Working on it right now.

from merit.

tute avatar tute commented on August 21, 2024

@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.

starmandell avatar starmandell commented on August 21, 2024

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.

tute avatar tute commented on August 21, 2024

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.

starmandell avatar starmandell commented on August 21, 2024

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.

tute avatar tute commented on August 21, 2024

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.

starmandell avatar starmandell commented on August 21, 2024

oh cool!
thanks! i look forward to the documentation.

thanks for being responsive and caring about user input = )

from merit.

starmandell avatar starmandell commented on August 21, 2024

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.

tute avatar tute commented on August 21, 2024

Nice, so, two things:

  1. 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!
  2. I'll add an error handler for inexistent badges.

We'll make this better and better! :-)

from merit.

starmandell avatar starmandell commented on August 21, 2024

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.

tute avatar tute commented on August 21, 2024

Fixed in v0.6.3, thanks for reporting! Merit is doing better. :-)

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.