Module: Decidim::SearchesHelper

Included in:
CardMCell
Defined in:
app/helpers/decidim/searches_helper.rb

Overview

A Helper to render and link to searchables.

Instance Method Summary collapse

Instance Method Details

#searchable_resource_human_name(resource, count: 1) ⇒ Object

Parameters:

  • count: (optional) (defaults to: 1)

    the number of resources so that the I18n backend can decide to translate into singluar or plural form.



7
8
9
# File 'app/helpers/decidim/searches_helper.rb', line 7

def searchable_resource_human_name(resource, count: 1)
  resource.model_name.human(count: count)
end

#searchable_resources_as_options(all_label) ⇒ Object



11
12
13
14
15
# File 'app/helpers/decidim/searches_helper.rb', line 11

def searchable_resources_as_options(all_label)
  [["", all_label]] + Decidim::Searchable.searchable_resources.values.collect do |r|
    [r.name, searchable_resource_human_name(r, count: 2)]
  end.sort
end