Good sample for Pagination with Many to Many Relationship?

Let’s say we have 2 tables with Many to many relationship?

Actors and Movies. Actors can be in many movies and movies have many
actors.

I want a query that does a text search on the Movie name and finds all
movies with the word “Shark” in it. The result page would be a list
sorted by Movie Title/Actor name like:

Movie Actor


Sharks Rule Barnes, Oscar
Sharks Rule Cole, Tony
Sharks Rule Kentz, Olivia
Teasing Sharks Hardy, Fool
Teasing Sharks Trouble, Wanting

I only want 25 Movie/Actor lines per page. Any good samples for getting
this done?

Regards

Hi,

Something like this might work…

def search
session[:pag_cache] ||= your_search_method
#with the return result formatted to work with “:conditions=>”
@movie_pages, @movies= paginate :movies, :order_by => ‘title ASC’,
:per_page => 25, :conditions=> session[:pag_cache]
end