simple search form - ruby newbie

Kathy Simmons
Wed, 13 Dec 2006 19:58:23 -0000

I have a simple search form - RoR displays form ok.  All IP Address are
loaded from db. I want to select one of the IP Addresses listed, press
Submit, and have all the data from that IP address displayed.  I am a
Ruby newbie - can someone help me figure out what I''m doing wrong?  I
select the IP Address and get a list of ALL data (not the data
associated with that IP)

Here is how I get my list of IP addresses - this works fine - the list
is displayed:


..........

Please select the item(s) to search
on.
<%= form_tag :controller => ''ip_address'', :action =>
''get_data'', :id =>
"@result" %>

Select IP Address:
<%= collection_select("IpAddress", "ip",
IpAddress.find_all, :id, "ip")
%>

............
<%= submit_tag "Get Data" %>
<%= end_form_tag %>
..............

Now in my IpAddressController I have the following defined:
def get_data
        condi = nil
        if params[:query]
           condi = ["ip LIKE ?", "%#{params[:query]}%"]
        end
        @result = Scan.find(:all, :conditions => condi)
  end
..................................

Then I simply print it out in a table...but what is being printed out
now is all the data, not just data associated with that IP.



Date
Type

    <% @result.each do |scan| %>

<%= scan.date %>
<%= scan.scanType.name
%>

    <% end %>


--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---