On Nov 21, 2008, at 1:58 PM, Charley Mills wrote:

>
> I'm having problems, all of a sudden, with some code that's been  
> working
> for years.  Someone else wrote this code, and I'm just trying to
> maintain it - I don't have expert experience with ruby or rails.  The
> code grabs all invoices processed within the past week for a customer
> and send an email to the appropriate person, like this:
>
>  # finds the most recent invoices for this organization
>  def find_recent_invoices(number=6)
>    date = (Time.now - number.days).to_date
>    invoices.find(:all, :order => 'posted_on asc', :conditions =>
> ["invoices.posted_on >= ?", date])
>  end
>
> I get this error:
>
> NoMethodError (private method `to_date' called for Sat Nov 15 13:32:51
> -0800 2008:Time):

I don't remember the particulars, but you've hit the mismatched ruby/ 
rails bug that came up about rails 1.2.3 I think it was.  Maybe  
1.2.6.  Anyway, at one point some methods went private in ruby that  
Rails used.  Or vice versa.  Anyway, the next version of rails put  
them back because people were used to them.  Google around for  
specifics.

In any event, I suspect you've either just recently updated Ruby or  
Rails when this problem started.

If it helps, the line giving you problems works for me with rails  
2.1.0 and ruby 1.8.6 (2008-03-03 patchlevel 114).

Change the code to this and it should work for you:

def find_recent_invoices(number=6)
   invoices.find(:all, :order => 'posted_on asc',
                 :conditions => ["invoices.posted_on >= ?",  
number.days.ago])
end


-philip






--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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