I'm trying to get a list of zip codes in my database with
zipstring = sprintf("select distinct zip from visits,households where " + "households.id=visits.household_id and visits.month='%2d' and visits.year = '%4d' " + "and visits.monthly = 1 order by households.zip;", datestart.month, datestart.year, dateend, datestart)
@ziplist = Household.find_by_sql(zipstring)
this gives me an array of zip codes. Then I use
<%= render :partial=>"monthly_report", :collection => @ziplist %>
to run monthly_report for each zip code. This is where the problem is. If I try to put the variable into a find call, it isn't text.
If I look at it in the debugger, it's
#<Household zip: "01501">
and .to_s is
"#<Household:0xb68ad9e4>"
All I need is the 01501 part, but I'm getting the memory address in my find call. Please help.
Thanks
Bob Smith <bsm2th@gmail.com>