cantango gem version: 0.9.4.3
Emilio
I'm currently doing some major refactoring of cantango, splitting it into smaller parts and improving the test suite to make sure the code is pretty much fully covered. I have been developing new features a bit "too fast" since 0.9 and not been testing all the pieces thoroughly enough, so I appreciate anytime one of you finds and notifies me of a bug.
You could also clone the repo and reference your local version from your project and then debug and make fixes yourself and then when fixed, make me a pull request ;)
Thanks!
Kristian
Hi Kristian,
Here https://gist.github.com/1cdbf67c876c0abeb635 is the trace for the
error. I'll try to understand what is happening and see if I can help.
Emilio
def all(CanTango.config.permits.available_types - [:special]).map{|p| send(p) if respond_to?(p)}end
def all(CanTango.config.permits.available_types - [:special]).map{|p| get p }endWell, would be better named as:def get_permit label…enddef all(CanTango.config.permits.available_types - [:special]).map{|label| get_permit label }end
def available_typesavailable_permits.keysend
def default_permitsdef available_permits@available_permits ||= default_permitsend
{ :user => CanTango::Permits::UserPermit,:account => CanTango::Permits::AccountPermit,:role => CanTango::Permits::RolePermit,:role_group => CanTango::Permits::RoleGroupPermit,:special => nil}end
On Nov 21, 2011, at 7:46 PM, Emilio wrote:
I tested the 0.9.4.5 and it now prints
permits registry:[#<Hashie::Mash>, #<Hashie::Mash>, #<Hashie::Mash>,
#<Hashie::Mash>]
And when I try a user_can?(...), I get a "no key", which is raised
when it tries to invalidate session[:permission], I guess. Here is the
trace for this error: https://gist.github.com/7eee1f2394f89a0cb8c8
Thanks,
Emilio
> > Herehttps://gist.github.com/1cdbf67c876c0abeb635is the trace for the
It means that cantango tries to cache the ability rules for the user, but that it doesn't know how to generate a unique hash for that user (cache key).
In order to do so, it needs to know of a unique field to use for that key, typically :email (#email method). You can configure (customize) which field/method to use (see Configuration in the wiki).
Check out the cantango-demo to see an example setup somewhat resembling the Quickstart tutorial. I might have missed a few things in the tutorial.
I should also have a FAQ page describing common errors/problems. Please also check the state of your User. Some people have been using User.new, where all attributes are nil, and thus email is also nil, which is not valid for generating the hash (cache) key.
Kris
After some debugging, I found that the session[cache_key] is not set
for cache_key = :permission, only for :rules_cache.
Emilio
> >>> Herehttps://gist.github.com/1cdbf67c876c0abeb635isthe trace for the
> >>>>> Herehttps://gist.github.com/1cdbf67c876c0abeb635isthetrace for the
cantango-0.9.4.5/lib/cantango/configuration/permits.rb:84
registry.get(permit_type)[permit_name] = permit_clazz
change to:
registry.get_permit(permit_type)[permit_name] = permit_clazz
Best regards
Eric
> >>>>>>> Herehttps://gist.github.com/1cdbf67c876c0abeb635isthetracefor the
could you push the fixes for the two bugs into the repo including a
new version bump, please?
Then, we could use the plugin in our team environment without having
every team member have to manually fix them..
Thanks a lot
Eric
Den 24/11/2011 kl. 11.05 skrev betasheet:
You can now configure the role/role groups system directly like this:
Cantango.config.roles.role_system = :troles
And the role_list method should be set "correctly" to match the given role system API. Same goes for role groups. Pushed to master branch for now.
module CanTango
class Configuration
class Roles < RoleRegistry
include Singleton
def role_system= name
raise ArgumentError, "Must be a label" if !name.kind_of_label?
@role_system = name.to_sym
end
def roles_list_map= role_systems_hash
raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_systems_hash}" if !role_systems_hash.kind_of?(Hash)
@roles_list_map = role_systems_hash
end
def role_system
@role_system ||= :troles
end
def add_role_system role_system_hash
raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_system_hash}" if !role_system_hash.kind_of?(Hash)
roles_list_map.merge! role_system
end
def default_has_method
:has_role?
end
def default_list_method
roles_list_map[role_system] || :roles_list
end
def roles_list_map
@roles_list_map ||= {
:troles => :role_list
}
end
end
end
end
Den 24/11/2011 kl. 11.05 skrev betasheet:
Thanks for your help!
Eric
Den 24/11/2011 kl. 14.39 skrev betasheet: