That'll return all posts that were created in the 10 days before the
application was started (because 10.days.ago is evaluated in the class
body). To return all posts that were created in the 10 days before the
query is run, you want:
has_many :posts, :conditions => proc { ['created_at >= ?', 10.days.ago] }
Mat
On Fri, Feb 12, 2010 at 05:51, Jared Armstrong
<[email protected]> wrote:
> has_many :posts, :conditions => 'created_at >= #{10.days.ago}'
>
> On Feb 12, 7:12 pm, Charanya Nagarajan <[email protected]> wrote:
>> Hi all
>>
>> I have a model called,article which belongs_to user
>> so in article.rb
>> belongs_to :user
>>
>> and in user.rb
>> has_many :posts, :dependent => :nullify, :class_name => 'Article'
>>
>> so now @user.posts is giving the posts of the user
>>
>> Now like,without using any named_scope,
>> i would want @user.posts to give out only the posts which were published
>> before 10 days.
>>
>> I know i can use a named_Scope
>> But i want to directly use @user.posts alone to get the above result.
>>
>> Is it possible to do this??
>>
>> Thanks In Advance,
>>
>> Charanya
>> --
>> Posted viahttp://www.ruby-forum.com/.
>
> --
> 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.
>
>
--
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.