def self.search(search, page)
paginate_by_sql [‘SELECT FROM posts WHERE #{time_difference created_at}
<= #{search}’], :per_page => 15, :page => page
end
I need something to this extent, where time_difference is a helper
method, created_at is the timestamp field for an activerecord object,
and search is a parameter passed into my self.search method.
Justin To wrote:
def self.search(search, page)
paginate_by_sql [‘SELECT FROM posts WHERE #{time_difference created_at}
<= #{search}’], :per_page => 15, :page => page
end
I need something to this extent, where time_difference is a helper
method, created_at is the timestamp field for an activerecord object,
and search is a parameter passed into my self.search method.
Correction, paginate_by_sql [‘SELECT FROM posts WHERE
#{Time.now.minus_with_coercion created_at} <= #{search}’]
Thanks! =)
On Aug 6, 7:56 pm, Justin To [email protected] wrote:
Correction, paginate_by_sql [‘SELECT FROM posts WHERE
#{Time.now.minus_with_coercion created_at} <= #{search}’]
Not quite sure what you’re after. something like
def search(time_diff_in_minutes)
… WHERE created_at <
#{time_diff_in_minutes.minutes.ago.to_s(:db)} …
end
?
Fred