Skip to content

Instantly share code, notes, and snippets.

@kinopyo
Created June 20, 2012 03:03
Show Gist options
  • Save kinopyo/2957917 to your computer and use it in GitHub Desktop.
Save kinopyo/2957917 to your computer and use it in GitHub Desktop.
Chanko active_if condition..
# 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