Module: Ramaze::Helper::Search
- Defined in:
- lib/zen/helper/search.rb
Overview
The Search helper is a helper that can be used in controllers allowing the user to search the content of those controllers and models.
Instance Method Summary (collapse)
-
- (String) render_search_form(url)
Renders a search form that points to the given URL.
-
- (NilClass|Mixed) search
Calls the given block used to search a number of records.
Instance Method Details
- (String) render_search_form(url)
Renders a search form that points to the given URL.
17 18 19 20 21 22 |
# File 'lib/zen/helper/search.rb', line 17 def render_search_form(url) render_file( __DIR__('../view/search.xhtml'), :url => url.to_s ) end |
- (NilClass|Mixed) search
Calls the given block used to search a number of records. If the search action raises an error a message is displayed and the user will be redirected back to the previous page.
If no search query is specified nil will be returned.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/zen/helper/search.rb', line 39 def search if request.params['query'].nil? or request.params['query'].empty? return nil end begin return yield(request.params['query']) rescue => e Ramaze::Log.error(e.inspect) (:error, lang('zen_general.errors.invalid_search')) redirect_referrer(::Sections::Controller::Sections.r(:index)) end end |