be aware that timestamps are not unique, i.e. they usually have no
millis or nanos. just a thought whether using them to iterate over
them.

- Kristian

On Tue, Jan 22, 2013 at 11:16 PM, kristian <m.krist...@web.de> wrote:
> take last instead of first :)
>
>> Audit.last( :id.lt => 10 )
> => #<Audit @id=9
>
> - Kristian
>
> On Tue, Jan 22, 2013 at 10:43 PM, Alex <a...@sicanstudios.com> wrote:
>> Thanks guys, the code works, however there is a problem. The .gt works fine,
>> but the .lt always gives me the first element in the db, not the previous
>> element! I tried it with both the :id (@post_id) and the :created_on
>> (@post_date) properties, getting the same result:
>>
>>>   def post_in_db
>>>     posts_of_user.each do |post|
>>>       if post.slug == params[:post_slug]
>>>         @post_slug ||= post.slug
>>>         @post_title ||= post.title
>>>         @post_body ||= post.body
>>>         @post_date ||= post.created_on
>>>         @post_private ||= post.private
>>>         @post_id ||= post.id
>>>         @previous = prev.title
>>>         @next = nexts.title
>>>       end
>>>     end
>>>   end
>>>   def prev
>>>     Post.first(:created_on.lt => @post_date)
>>>   end
>>>   def nexts
>>>     Post.first(:created_on.gt => @post_date)
>>>   end
>>
>>
>> Any ideas?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "DataMapper" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/datamapper/-/278-qTqCbrsJ.
>>
>> To post to this group, send email to datamapper@googlegroups.com.
>> To unsubscribe from this group, send email to
>> datamapper+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/datamapper?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to