Albums

------------------------------------------------------------------------------ after_save :update_albums def album_ids=(ids) if new_record? @new_album_ids = ids.reject(&:blank?) else self.albumizations.each { |z| z.destroy unless ids.delete(z.album_id.to_s) } ids.reject(&:blank?).each {|id| self.albumizations.create(:album_id => id) } end end def album_ids new_record? ? @new_album_ids : albums.map(&:id) end private def update_albums self.album_ids = @new_album_ids if @new_album_ids end ------------------------------------------------------------------------------- <% content_for :secondary do %>

Albums

<% end -%> ------------------------------------------------------------------------------- def next(album=nil) collection = album ? album.photos : self.class.find(:all) collection.size == collection.index(self) + 1 ? collection.first : collection[ collection.index(self) + 1 ] end def previous(album=nil) collection = album ? album.photos : self.class.find(:all) collection[ collection.index(self) - 1 ] end