Rails: paginate association with to_json/to_xml

redfield62

New Member
I have a model called Playlists which has_and_belongs_to_many :songsIn my PlaylistController I call respond_with(@playlist, :include => :songs) so I can return both json and xml output.However, some playlists have hundreds of songs. So I would like to let the caller send ?limit=X&offset=Y with the call (with default values 25 and 0 respectively). But how I do pass this limit and offset to the association during serialization? I [email protected] = @playlist.songs.limit(l).offset(o)But that had some unfortunate results. :(Any ideas?
 
Back
Top