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:
<body>
..........
<div class="h1">Please select the item(s) to search
on.</div>
<%= form_tag :controller => ''ip_address'', :action =>
''get_data'', :id =>
"@result" %>
<p><label>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.
<table id=''scan_tbl''>
<tr>
<td class="tableheader">Date</td>
<td class="tableheader">Type</td>
</tr>
<% @result.each do |scan| %>
<tr>
<td class="tabletext"><%= scan.date %></td>
<td class="tabletext"><%= scan.scanType.name
%></td>
</tr>
<% end %>
</table>
--
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
-~----------~----~----~----~------~----~------~--~---