I am using rails 3.0.9, cancan 1.6.7 and developing 1.4.8
I use two development models (User and Admin) for different registration and registration processes
So, I want to share the abilities that depend on the registered user (resource), because there are more than 70 models and only 10 models are common for both types of users (here, more than 50 models and views are used only by Admin users)
I want to implement two skill classes (UserAbility and AdminAbility), and the helper method current_user / current_admin should be passed to UserAbility / AdminAbility
Example:
In ApplicationController.rb
def current_ability if current_user @current_ability = UserAbility.new(current_user) elsif current_admin @current_ability = AdminAbility.new(current_admin) end end
From my questions above,
Perhaps there are several classes of features in cancan, if possible, how to create them, because I tried
rails g cancan:user_ability
but I got an error like Could not find the cancan: user_ability generator .
How to choose the appropriate skill class for the registered user / administrator.
If both the user and the administrator are accessing the controller, how can I get the currently registered User / Admin object
Is there any other solution for this?
Anyone please help solve this problem.
source share