Tuesday, 10 April 2012

Active Record Queries in Rails 3


Hi,

Rails 3 has Introduced many methods in ActiveRecord.

Here is the list of Active Record Queries in Rails 3 that I have used in my daily application developement.

    subscriptions = Subscription.where(
        :renewal => (Date.today-6)..(Date.today),
        :status => 'pending',
        :retry_count => 0..3,
        :retry_date => NIL )

 
   In the above query, 'renewal' column is a date datatype. By running query with (Date.today-15)..(Date.today) will fetch the records inbetween those dates.



Thank You,
Uma Mahesh    



No comments:

Post a Comment