After some thinking I finally decided to use following code:

in controller:
@jobseeker_previous = Jobseeker.find :all, :order => 'id
DESC',  :conditions => ["id < ?",@jobseeker.id], :limit => 1
@jobseeker_next = Jobseeker.find :all,  :order => 'id
ASC',  :conditions => ["id > ?",@jobseeker.id], :limit => 1

in view:
<%...@jobseeker_previous.each do |el|%>
<%= link_to 'Previous', el %>
<% end %>

<%...@jobseeker_next.each do |el|%>
<%= link_to 'Next', el %>
<% end %>

I tried few solutions and this one, where I get a collection
containing one element, seems to be most convenient for handling first
and last record, and is more idiot proof than unnecessarily having to
test for nil object.

-- 
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.

Reply via email to