i’m after suggestions. Here’s what i’m trying to do.
I’m using Rails with Thinking Sphinx to search my Database of Books. A bit like this:
results = Books.search 'blabla' :where => {:author => author_id}
Which works fine and resturns me an array of results. I then loop over each result and display book information back in a pretty grid. Lovely Jubly.
However, because I eventually want my website to make money i’m selling advertising on this site and ideally i’d like the ads to be positioned within the same grid as the results, after say every 5 results i’d like to show an advert.
I’ve racked my little brain but cannot think of a simple way to do this. So I thought i’d ask you clever people.
Any suggestions are welcome.
Thanks!
In your view you could use
elements.each_slice(4) do | batch |on your result set to break it up.Ex: