Help with prev/next links

I've written a Image Gallery app in rails. It contains photo albums, in which you can upload photos, then click on an individual photo to view it's larger size. When you bring up the larger size, I have previous and next buttons to go through the photos in the album. My problem is when navigating through photos via the next and previous buttons, it scrolls through ALL photos instead of photos only in that album.

Previous and Next buttons in picture.html.erb

  <section id="prev">     <%= link_to("Previous", @photo.previous_photo) if @photo.previous_photo %>   </section>

  <section id="next">     <%= link_to("Next", @photo.next_photo) if @photo.next_photo %>   </section>

Methods in model

  def previous_photo     self.class.first(:conditions => ["id < ?", id], :order => "id desc")   end

  def next_photo     self.class.first(:conditions => ["id > ?", id], :order => "id asc")   end

Method in Albums Controller

  def picture     @photo = Photo.find(params[:id])   end

I tried doing it like this:

  <%= link_to("Previous", @album.photo.previous_photo) if @album.photo.previous_photo %>

  def picture     @album = Album.find(params[:id])     @photo = Photo.find(params[:id])   end

With this result:

  Couldn't find Album with ID=25