Module: EffectivePollsHelper
- Defined in:
- app/helpers/effective_polls_helper.rb
Instance Method Summary collapse
-
#effective_polls_audience_scope_collection ⇒ Object
Used by admin/polls form.
Instance Method Details
#effective_polls_audience_scope_collection ⇒ Object
Used by admin/polls form
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/effective_polls_helper.rb', line 4 def effective_polls_audience_scope_collection # Normalize the collection into [[label, value], [label, value]] scopes = Array(EffectivePolls.audience_user_scopes).map do |key, value| (key.present? && value.present?) ? [key, value] : [key.to_s.titleize, key] end # Makes sure the User model responds to all values scopes.each do |_, scope| unless defined?(User) && User.respond_to?(scope) raise("invalid effective_polls config.audience_user_scopes value. The user model must respond to the scope User.#{scope}") end end # Append the number of users in this scope scopes.map! do |label, scope| ["#{label} (#{pluralize(User.send(scope).count, 'user')})", scope] end end |