Class: Cms::HtmlBlock
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cms::HtmlBlock
- Defined in:
- app/models/cms/html_block.rb
Class Method Summary collapse
- .display_name ⇒ Object
- .display_name_plural ⇒ Object
- .eager_matching(term) ⇒ Object
-
.search(search_params) ⇒ Object
Override of search scope from searching behavior to deal with include_body.
Class Method Details
.display_name ⇒ Object
29 30 31 |
# File 'app/models/cms/html_block.rb', line 29 def self.display_name "Text" end |
.display_name_plural ⇒ Object
33 34 35 |
# File 'app/models/cms/html_block.rb', line 33 def self.display_name_plural "Text" end |
.eager_matching(term) ⇒ Object
12 13 14 |
# File 'app/models/cms/html_block.rb', line 12 def self.eager_matching(term) "%#{term}%" end |
.search(search_params) ⇒ Object
Override of search scope from searching behavior to deal with include_body
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/cms/html_block.rb', line 16 def self.search(search_params) term = search_params.is_a?(Hash) ? search_params[:term] : search_params include_body = search_params.is_a?(Hash) ? search_params[:include_body] : false conditions = ["name like lower(?)", eager_matching(term)] if include_body conditions[0] << "OR content like lower(?)" conditions << eager_matching(term) end where(conditions) end |