-
Notifications
You must be signed in to change notification settings - Fork 198
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
Support for controller namespace(s) #40
Comments
I'm also having this problem when integrating Merit with Forem and other engines. Namespacing awareness would be great. |
Thanks for your feedback. Certainly this is a bug, as rules are in these cases ambiguous. You are right @emq: the only problem in adding the namespace with The two options that I can now think of are:
A mix of the two seems like the best options: try the namespaced model, catch a possible Thanks again for your feedback! |
Thanks for being on top of things. The case you mention only raises the NameError if the class does not exist, if there was an Admin::User constant, it would work just fine. I've manage to get it working by changing controller_name to controller_path in the target_model of the action and on the rules_defined? method. Then I define the rule as This has worked for me at least with the badges, but I believe it should work with points and rank as well. |
When the class exists yes, it would work even without the |
Great! I'll use my patched version until then, but will be on the lookout for the new version. |
Version 1.2.1 just released with a small API change (see https://github.com/tute/merit/blob/master/UPGRADING.md). |
Hi!
First of all - thank you for this fine gem, I'm going to use it on my upcoming application :). But - it appears I've found a small bug (or maybe support for it wasn't ever intended?) when it comes for using multiple controllers of the same name under different namespace (eg. for frontend and backed).
Let's say I have a badge rule binded to
users#update
, but I also haveAdmin::UsersController
also withupdate
action. You can guess what happens - it blows in you face (so to speak).In
merit/lib/merit/controller_extensions.rb
you have thisafter_filter
that checks defined rules:What you should use is
controller_path
that returns full path (with namespace) and you should be fine... But apparently you won't because it goes deeper toMerit::Action
class, as you saveaction_method
andtarget_model
without distinguishing the controller namespace.I thought I could be able to make a quick fix for this, but I don't think it will be so quick and I don't want to break something else by accident. I hope I didn't mixed up anything :).
Best regards!
The text was updated successfully, but these errors were encountered: