Help with with displaying a selected list.

Hello. I call a find_all_by_subject("action") which returns 2 videos
and displays them properly. But when I add @video_pages, @videos =
paginate :videos, :per_page => 10 so I can paginate the videos, it
displays ALL the videos as if I selected list videos. Can someone
please tell me what I am doing wrong? Thank you.

selectaction.rhtml

<table>
  <tr>
  <% x = 0 %>
  <% for video in @videos %>
    <td><%= link_to(image_tag("videos/#{video.video_thumbnail}",
                               :size => '132x99',
                               :border => 5,
                               :id => 'thumbnail'),
                    url_for(:action => 'show', :id => video)
                   )
         %><br>
    <b>Title:</b> <%= h video.title %><br>
    <% x = x + 1 %>
    <% if x % 2 == 0 %>
      <%= "</td></tr><tr>" %>
    <% else %>
      <%= "</td>" %>
    <% end %>
<% end %>
</tr>
</table>

<%= link_to 'Previous page', { :page => @video_pages.current.previous }
if @video_pages.current.previous %>
<%= link_to 'Next page', { :page => @video_pages.current.next } if
@video_pages.current.next %>

Controller
class VideosController < ApplicationController
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @video_pages, @videos = paginate :videos, :per_page => 10
  end

  def show
    @video = Video.find(params[:id])
  end

  def new
    @video = Video.new
  end

  def create
    @video = Video.new(params[:video])
    if @video.save
      flash[:notice] = 'Video was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @video = Video.find(params[:id])
  end

  def update
    @video = Video.find(params[:id])
    if @video.update_attributes(params[:video])
      flash[:notice] = 'Video was successfully updated.'
      redirect_to :action => 'show', :id => @video
    else
      render :action => 'edit'
    end
  end

  def destroy
    Video.find(params[:id]).destroy
    redirect_to :action => 'list'
  end

  def selectaction
    @videos = Video.find_all_by_subject("action")
    @video_pages, @videos = paginate :videos, :per_page => 10
  end

end

jimjohnlists@yahoo.com wrote:

Hello. I call a find_all_by_subject("action") which returns 2 videos
and displays them properly. But when I add @video_pages, @videos =
paginate :videos, :per_page => 10 so I can paginate the videos, it
displays ALL the videos as if I selected list videos. Can someone
please tell me what I am doing wrong? Thank you.

*snip*

def selectaction
   @videos = Video.find_all_by_subject("action")
   @video_pages, @videos = paginate :videos, :per_page => 10
end

I think you need to put the conditions on the paginate request. In the 2nd line of the selectation action, your previous value of the variable "videos" is overwritten.

I don't have the syntax here, though. I'll send it out later. I think it's something like:
   @video_pages, @videos = paginate :videos, :per_page => 10, :conditions => 'subject = action'

Cheers
Mohit.

Mohit Sindhwani wrote:

Hello. I call a find_all_by_subject("action") which returns 2 videos
and displays them properly. But when I add @video_pages, @videos =
paginate :videos, :per_page => 10 so I can paginate the videos, it
displays ALL the videos as if I selected list videos. Can someone
please tell me what I am doing wrong? Thank you.

*snip*

def selectaction
   @videos = Video.find_all_by_subject("action")
   @video_pages, @videos = paginate :videos, :per_page => 10
end

I think you need to put the conditions on the paginate request. In the 2nd line of the selectation action, your previous value of the variable "videos" is overwritten.

I don't have the syntax here, though. I'll send it out later. I think it's something like:
  @video_pages, @videos = paginate :videos, :per_page => 10, :conditions => 'subject = action'

Cheers
Mohit.

OK, here's the example:
       @video_pages, @videos = paginate(:videos,
                                      :per_page => 20,
                                      :conditions => @condition,
                                      :conditions => ['subject = ?', 'action']
                                      )
Cheers
Mohit.