Report abuse

controller


			
def list
  @videos = if (@category = Category.find_by_slug params[:slug])
    # if category is given, we will scope to it
    @category.videos
  else
    # no category, simply paginate all videos
    Video
  end.paginate(:per_page => 20, :page => params[:page])

  # first 2 videos on page 1
  @featured = []

  if @videos.current_page == 1
    @featured << @videos.shift
    @featured << @videos.shift
  end
end

view


			
<% unless @videos.empty? and @featured.empty? %>

  <% for video in @featured %>
    <%= video.name %>
    #photo display
  <% end %>

  <% for video in @videos %>
    <%= video.band.name %>
    #list display
  <% end %>

<% else %>
  

Sorry, there aren't any videos in this category!

<% end %>