Homer Simpson
2006-Sep-05 14:59 UTC
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Fernanda
2006-Sep-05 22:06 UTC
Re: Good sample for Pagination with Many to Many Relationship?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---