Module: Alchemy::PgSearch::SearchHelper
- Defined in:
- app/helpers/alchemy/pg_search/search_helper.rb
Instance Method Summary collapse
- #highlighted_excerpt(text, phrase, radius = 50) ⇒ Object
-
#render_search_form(options = {}) ⇒ Object
Renders a search form.
Instance Method Details
#highlighted_excerpt(text, phrase, radius = 50) ⇒ Object
36 37 38 |
# File 'app/helpers/alchemy/pg_search/search_helper.rb', line 36 def highlighted_excerpt(text, phrase, radius = 50) highlight(excerpt(text, phrase, radius: radius).to_s, phrase) end |
#render_search_form(options = {}) ⇒ Object
Renders a search form
It queries the controller and then redirects to the search result page.
Example search results page layout
Only performs the search if ferret is enabled in your config/alchemy/config.yml
and a page is present that is flagged with searchresults
true.
# config/alchemy/page_layouts.yml
- name: search
searchresults: true # Flag as search result page
Note
The search result page will not be cached.
26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/alchemy/pg_search/search_helper.rb', line 26 def render_search_form( = {}) = { html5: false, class: "fulltext_search", id: "search", } search_result_page = Alchemy::Search::SearchPage.search_result_page render "alchemy/search/form", options: .merge(), search_result_page: end |