Skip to content

Instantly share code, notes, and snippets.

@kennethgeerts
Created October 16, 2014 06:46
Show Gist options
  • Select an option

  • Save kennethgeerts/16ac061c201d1edb7b74 to your computer and use it in GitHub Desktop.

Select an option

Save kennethgeerts/16ac061c201d1edb7b74 to your computer and use it in GitHub Desktop.

Revisions

  1. Kenneth Geerts created this gist Oct 16, 2014.
    11 changes: 11 additions & 0 deletions helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    def search_field(field, operator, attributes = {})
    field_op = "#{field}_#{operator}"
    value = (params[:q][field_op] if params[:q])
    title = t(".#{field_op}")
    label_tag = content_tag :label, title
    attributes[:name] = "q[#{field_op}]"
    attributes[:type] ||= 'text'
    attributes[:value] = value
    input_tag = content_tag :input, nil, attributes
    [label_tag, input_tag].join.html_safe
    end