Data Comparison

Jeff Miller
Thu, 07 Feb 2008 23:19:08 -0000

Hello,
 I am having trouble trying to get a data table comparison working... I
have two database tables with their own models. Both contain phone
number information. What I need the program to do is to read every phone
number from every row from Table1 and compare that number to every
number in every row in Table2. It then needs to put that information in
two variables. One containing all the entries that match in both tables
and one containing all the entries that do not match. I am very new to
RoR and I can do this no problem in PHP, but my boss wants it in Ruby...
I have a "compare" controller in which all this should take place. I
have tried using find_by_sql with no luck... I think my big problem is
simply not defining variables properly or something. My controller looks
like this: Btw, "bes" is one table (holding Blackberry phone info) and
"prov" is another table (holding info from our wireless provider).

def index
 @bes = Bes.find(:all)
 @prov = Import.find(:all)

 @provnumber = Import.prov_service_number
 @matches = Bes.find_by_sql("SELECT bes_phonenumber number,
bes_displayname name      FROM bes WHERE bes_phonenumber = @provnumber")
end

My view has something like this:

<% for match in @matches -%>
<% @matches %>

<%= match.name %>
<%= match.number %>
<%= match.prov_number %>

<% end %>

Thanks for all your help! I appreciate it!
 - Jeff
--
Posted via http://www.ruby-forum.com/.