james2m / canard

Makes role based authorization in Rails really simple. Wraps CanCan and RoleModel up with a smattering of syntactic sugar, some generators and scopes.
MIT License
125 stars 28 forks source link

Added prefix optional parameter for acts_as_user method #26

Closed sintro closed 7 years ago

sintro commented 9 years ago

Faced the problem, when generated buy "add_role_scopes" methods conflicted with methods, generated by has_many relation (or any other relation or scope). I wanted to save most of canards methods and didnt want to rename my relations. So I made the possibility to add the prefix for generated "positive" scopes. So, User.children will be User.#{prefix}_children, for example.

james2m commented 9 years ago

Hey @sintro Thanks for this. Any chance of some tests, then I'll be happy to merge.

J.

sintro commented 9 years ago

Ok, I think will do it some later. Do you have any suggestions to renaming "prefix" option to something?

james2m commented 9 years ago

Prefix seems a pretty reasonable name to me. It's consistent with other methods like rails delegate.

sintro commented 9 years ago

Looks like I have not enought time to make tests. Not because new features are complex, but because I am really noob in MiniTest, and testing of gems. So, may be much later, or with someone`s help. I can describe some examples, but how to implement them - too hard for me now (

james2m commented 9 years ago

No problem, it’s the nature of open source. I’ll put the change into a development branch when I do the next round of updates and look at adding tests. :)