My code is..
controller
    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)

view - monthly.html.erb
        <%= render :partial=>"monthly_report", :collection => @ziplist %>

view - _monthly_report.html.erb
<%=   @oxtotalstring = Household.find(:all, :conditions =>
["households.zip = ?,households.id=visits.household_id,
visits.month=?, visits.year = ?, visits.monthly = '1'",
monthly_report, datestart.month, datestart.year ], :include
=> :visits, :order => "zip" ) %>

model
class Visit < ActiveRecord::Base
  belongs_to :household
class Household < ActiveRecord::Base
  has_many :visits, :dependent => :destroy



when I try this, the monthly_report variable in the partial looks like
this..
Household_zip: "01537"

The only reason I'm using a find call here is that later in the code I
need to render a partial for each record found, then see child tables
from that variable, as in monthly_report.people. From what I've seen,
this functionality is lost using find_by_sql.

if I remove the ? and monthly report from the find call and put a
sample zip code in, it works fine. Is there some way to translate this
to a string I'm missing? I tried monthly_report.to_s and got the same
result.


Thanks for the help

Bob Smith <[email protected]>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to