How to send params from user input to find_all in controller?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Moh
    New Member
    • Jul 2007
    • 4

    How to send params from user input to find_all in controller?

    I use form_remote_tag and text_field_tag to send select scope to controller.
    It returns a long string instead of a data set (collection).
    Please teach me how to use input field to control dynamic finder and return a "data set' object. So the returning object can be display in table with gird, paging....

    Thanks.


    Code:
    Code:
    class ContractorController < ApplicationController 
    
     def show
           term = params[:contractor_name] 
                  @contractor =  Contractor.all(:conditions => ["contractor_name LIKE ?", "#{term}" + "%"]) 
            
    end
    
       <% form_remote_tag(:update => "test_Ajx",
                           :controller => "Contractoradmin", 
                            :url => {:action => :show},
                            :method => "get", 
                            :option => "top") do  %> 
                            
             Contract Name:               
             <%= text_field_tag :contractor_name %>
             <%= submit_tag "Set", :onclick=> "doloadData()" -%>
     <ul id = test_Ajx>
            <li>Original item...Pleae add more!</li>
        </ul>
        <% end %>
Working...