Skip to content

Instantly share code, notes, and snippets.

@kennethgeerts
Created October 16, 2014 06:46
Show Gist options
  • Save kennethgeerts/16ac061c201d1edb7b74 to your computer and use it in GitHub Desktop.
Save kennethgeerts/16ac061c201d1edb7b74 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment