Closed JeanMertz closed 11 years ago
@JeanMertz,
For backwards compatibility, Authority lets you define your authorization methods with one or two arguments using some @nathanl black magic. Do your AccountAuthorizer's class and instance both take two arguments? (user, options={})
@adamhunter Thank you for explaining. This was indeed the problem. I've read through the documentation again and did find the warning about this:
This would ultimately call
creatable_by?
on the designated authorizer with two arguments: the user and{:for => @post}
. If you've defined that method yourself, you'd need to ensure that it accepts the options hash before doing this, or you'd get a "wrong number of arguments" error.
No problem! Glad you're liking Authority.
Thanks @adamhunter for answering this question. Thanks to @JeanMertz for raising this issue, too. Having the stack trace point to Forwardable
doesn't make it obvious where the problem is, so maybe I can try raising a more explanatory exception. I'll give it some thought.
Reopening so I won't forget to look into this. :)
@JeanMertz - would you try duplicating this issue using the remove_forwardable
branch in your project? I think it will give you a clearer backtrace. If so, I will merge it to master.
Merged pull request.
@nathanl sorry for not responding sooner. I've been pulled off into other projects that didn't use Authority (yet), so haven't had a chance to look at this.
Anyway, awesome of you to fix this, should ease on the head-scratching when things break.
You're very welcome. I want Authority to be easy to work with, so I appreciate hearing about anything confusing.
I'm having some issues implementing Authority for my controller actions. It seems that Ruby chokes somewhere in the
method_missing
call stack. I am using Ruby 2.0, could it be related to this?Here's the stack trace:
It all started with
resource
not being available inAccountAuthorizer#readable_by?
, so I tried setting some options, this broke things:authorize_action_for(accounts.first, :testing => accounts)