Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is an error in the documentation: current_user.add_badge => current_user.sash.add_badge #48

Closed
rfernand opened this issue Jan 11, 2013 · 6 comments

Comments

@rfernand
Copy link

I just did not know were to notify this, so I will post it right here:

There is an error in the documentation, to add a badge manually to an user is not current_user.add_badge, one has to use current_user.sash.add_badge instead.

Greetings!

@tute
Copy link
Member

tute commented Jan 11, 2013

Hi @rfernand. Which version are you using? Can you please add a stacktrace, or specify the necessary steps to see this?

add_badge, along with badge_ids, badges, points, rm_badge, add_points and substract_points are methods that internally get delegated to sash. Sash should be invisible to applications. Thanks for reporting!

@tute
Copy link
Member

tute commented Jan 11, 2013

It's actually tested in https://github.com/tute/merit/blob/master/test/integration/navigation_test.rb#L18-L20. I'll close the issue to not confuse other programmers, but I'm interested in following up what happened in your app.

@tute tute closed this as completed Jan 11, 2013
@rfernand
Copy link
Author

I am using Rails 3.2.11, with:
merit (1.0.1)
ambry (~> 0.3.0)
When i try to use add_badge or rm_badge in my has_merit model, an undefined method is thrown:

irb(main):003:0> user.add_badge
NoMethodError: undefined method `add_badge' for #<User:0x00000006e00848>
        from /usr/lib/ruby/gems/1.9.1/gems/activemodel-3.2.11/lib/active_model/attribute_methods.rb:407:in `method_missing'
        from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_methods.rb:149:in `method_missing'
        from (irb):3
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
        from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

The weird thing is that I can call user.points, user.badges, user.badge_ids, user.add_points/substract_points without problems.

Greetings!

@tute
Copy link
Member

tute commented Jan 11, 2013

I'm surprised it even works, we are not supporting Rails 2.3 yet! In fact we use ARel syntax in many places.

I think add_badge was added since version 1.2.0, so it makes sense you have to go through sash. You could also use Badge#grant_to(meritable_object), which is since 1.2.0 invalid syntax.

@rfernand
Copy link
Author

Oh, I misstyped, it was Rails 3.2.11 (as you can see that in the backtrace). I will update my merit gem and check it again.

@rfernand
Copy link
Author

Yes, updating merit worked as expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants