I have a list of people I am using as the collection for a
render :partial. This is for a list of users that is being made into a
pdf. I need to do 3 find calls to find out their attendance for the
last 3 years. The only way I can find to do this is to have the print
function call its view and have the find code in there, but I know
that's wrong.. Please point me in the right direction. Maybe a way to
put the login in the controller ?? Is there a way to add some logic to
the beginning of a render ??

  def print
    debugger
    @today = Date.today
    @year = @today.year
    @households = Household.find(:all, :order => "last_name,
first_name")
    @churches = Church.find(:all, :order => "name").map {|u| [u.name,
u.id]}

    respond_to do |format|
     # format.html # index.html
    #  format.xml { head :ok }
   #   format.pdf { send_data render_to_pdf({ :action =>
'log', :layout => 'pdf_report' }) }
       format.pdf { send_data render_to_pdf(  :action => 'print',
                                              :layout =>
'pdf_report'),
                                              :filename => "households
for " + Time.now.to_s(:long) + ".pdf" }
    end
  end


    <% @households.each do |@household| %>
        <%  @thisyear =
Visit.find_or_create_by_household_id_and_year(:household_id =>
@household, :year => @year) %>
        <%  @lastyear =
Visit.find_or_create_by_household_id_and_year(:household_id =>
@household, :year => @year-1) %>
        <%  @twoyearsago =
Visit.find_or_create_by_household_id_and_year(:household_id =>
@household, :year => @year-2) %>
        <%= render :partial=>"print" %>
    <% end %>

-- 
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