Module: LookingForHelper
- Defined in:
- lib/looking_for/helpers/looking_for_helper.rb
Instance Method Summary collapse
-
#looking_for(*args) ⇒ Object
Looking For Helper.
Instance Method Details
#looking_for(*args) ⇒ Object
Looking For Helper
Creates a link tag to open LookingFor search form with the given options.
Signatures
looking_for(object_name, method_names, link_body, = {}, = {})
-
object_name
- A model name, for example ‘Item’ or a collection in a one-to-many association (for example ‘user.items’ if user has many items). -
method_names
- An array of method names for build the results columns (for example [:id, :code, :description] if id, code, description are attributues of object_name) -
link_body
- The link body
options
-
:fill
- Fill html input with value from database ( db_field => input_tag_id ) when a row is selected. -
:width
- Width of dialog, optional, default 500px. -
:height
- Height of dialog, optional, default 300px.
html_options
Like html_options in link_to helper but :remote will be always true.
Examples
<%= looking_for 'Item',
[:id,:code,:description],
'search',
{ :fill => {:id => :item_id,
:code => :item_code,
:description => :item_description},
:width => 550,
:height => 360},
:id => 'looking_for_items' %>
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/looking_for/helpers/looking_for_helper.rb', line 37 def looking_for(*args) opt = args[3] || {} opt[:controller] = :looking_for opt[:action] = :search opt[:width] ||= 500 opt[:height] ||= 300 opt[:object_name] = args.first opt[:method_names] = args[1] html_opt = args[4] || {} html_opt[:remote] = true link_to args[2], opt, html_opt end |