I''m making a database of the video library for an anime club I help
out with, and I eventually want to extend it so reviews can be given
for titles (rather than discs). With that in mind (and a hope for less
duplication in the db), I''ve separated the titles of series/movies out
into a separate table. I have a videos table that has a title_id, and
the proper statements in the models to reflect that (Video belongs_to
:title, Title has_many :videos).
I wanted to get the list of videos in alphabetic order by title and
disc number, so my paginate statement looks like this
@video_pages, @videos = paginate :video, { :per_page => 40,
:join => "LEFT OUTER JOIN
titles ON titles.id = videos.title_id",
:order_by => ''titles.name,
disc_number''
}
The problem I''m having with this is that after this executes, in
@videos each video''s id has been replaced with the title_id.
Currently I''m doing something pretty hacky to fix it:
@videolist = Video.find( :all, :include => [:title] )
@videolist.each do |v|
@videos.each do |video|
if v.title == video.title && v.disc_number == video.disc_number
video.id = v.id
video.name = video.title.name
end
end
end
It seems that I shouldn''t have to do that, though. Is this a problem
with what paginate does?
--
Chris