Class: Decidim::Budgets::ProjectSearch
- Inherits:
-
ResourceSearch
- Object
- ResourceSearch
- Decidim::Budgets::ProjectSearch
- Defined in:
- app/services/decidim/budgets/project_search.rb
Overview
This class handles search and filtering of projects. Needs a ‘current_component` param with a `Decidim::Component` in order to find the projects.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ProjectSearch
constructor
Public: Initializes the service.
-
#results ⇒ Object
Returns the random projects for the current page.
-
#search_search_text ⇒ Object
Handle the search_text filter.
Constructor Details
#initialize(options = {}) ⇒ ProjectSearch
Public: Initializes the service. component - A Decidim::Component to get the projects from.
11 12 13 |
# File 'app/services/decidim/budgets/project_search.rb', line 11 def initialize( = {}) super(Project.all, ) end |
Instance Method Details
#results ⇒ Object
Returns the random projects for the current page.
23 24 25 |
# File 'app/services/decidim/budgets/project_search.rb', line 23 def results Project.where(id: super.pluck(:id)) end |
#search_search_text ⇒ Object
Handle the search_text filter
16 17 18 19 20 |
# File 'app/services/decidim/budgets/project_search.rb', line 16 def search_search_text query .where(localized_search_text_in(:title), text: "%#{search_text}%") .or(query.where(localized_search_text_in(:description), text: "%#{search_text}%")) end |