Created
June 20, 2012 03:03
-
-
Save kinopyo/2957917 to your computer and use it in GitHub Desktop.
Chanko active_if condition..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original | |
active_if any(:staff_beta?, :qa_ext_target?) | |
# In addition to above, I want to active extension when controller is `professional_users` | |
active_if do |context, options| | |
user = context.instance_variable_get("@login_user") | |
next unless user | |
next true if user.staff? | |
next true if user.release_target?(ReleaseTarget::QA_EXT_RELEASE_GROUP) | |
context.instance_eval do | |
next true if controller_name == 'professional_users' | |
end | |
end | |
# It's not exactly same code as the original one, | |
# staff is active by default, no matter if he/she turn on or off the extension. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment