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

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

<%= 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

URIs, Addressability, and the use of HTTP GET and POST)
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

[email protected] wrote:

@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 S. wrote:

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.