Skip to content

Instantly share code, notes, and snippets.

@trusche
Last active January 31, 2023 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trusche/ed3521a17b52fdd6a43687cc5c45b999 to your computer and use it in GitHub Desktop.
Save trusche/ed3521a17b52fdd6a43687cc5c45b999 to your computer and use it in GitHub Desktop.
class AccountsAddFeatures < ActiveRecord::Migration[6.0]
def change
add_column :accounts, :features, :citext, array: true, null: false, default: []
add_column :users, :features, :citext, array: true, null: false, default: []
end
end
class ApplicationPolicy
# ... pundit stuff
def enabled?(feature)
user.enabled?(feature) || user.account.enabled?(feature)
end
def disabled?(feature)
!enabled?(feature)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment