sorry, missed one ]
story = PaymentHistory.where(["company_id = ? AND created_at <= ? AND create_at
>= ?", company.id, time, time - 1.month]).try(:first)
On Jul 24, 2011, at 19:55 , Tom Meinlschmidt wrote:
>
> use array, so try
>
> time = Time.now
> story = PaymentHistory.where(["company_id = ? AND created_at <= ? AND
> create_at >= ?", company.id, time, time - 1.month ).try(:first)
>
> NEVER use direct inserting of values into SQL query
>
> and "first" could end with "nil.first", so use try()
>
> tom
>
> On Jul 24, 2011, at 6:56 , Rodrigo Ruiz wrote:
>
>> Hi, Id like to do something like that:
>>
>> @payment_history = PaymentHistory.where("company_id = #{@company.id} AND
>> created_at <= #{Time.now} AND create_at >= #{Time.now - 1.month}").first
>>
>> problem is it doesn't seen to let me compare the create_at attribute with
>> Time.now.
>>
>> Anyone knows the proper way to do this?
>>
>> Thank you,
>> Rodrigo
>>
>>
>> --
>> 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.
>
> --
> ===============================================================================
> Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
>
> www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
> ===============================================================================
>
> --
> 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.
--
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
===============================================================================
--
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.