Module: TalentScout::Helper
- Defined in:
- lib/talent_scout/helper.rb
Instance Method Summary collapse
-
#link_to_search(name, search = nil, html_options = nil, &block) ⇒ String
Renders an anchor element that links to a specified search.
Instance Method Details
#link_to_search(name, search, html_options = nil) ⇒ String #link_to_search(search, html_options = nil, &block) ⇒ String #link_to_search(name, search_options, html_options = nil) ⇒ String #link_to_search(search_options, html_options = nil, &block) ⇒ String
Renders an anchor element that links to a specified search. The search is specified in the form of a ModelSearch search object, which is converted to URL query params. By default, the link will point to the current controller and current action, but this can be overridden by passing a search_options
Hash in place of the search object (see method overloads).
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/talent_scout/helper.rb', line 58 def link_to_search(name, search = nil, = nil, &block) name, search, = nil, name, search if block_given? if search.is_a?(Hash) = search.dup search = .delete(:search) else = {} end raise ArgumentError, "`search` cannot be nil" if search.nil? [:controller] ||= controller_path [:action] ||= action_name [search.model_name.param_key] = search.to_query_params if block_given? link_to(, , &block) else link_to(name, , ) end end |