In the railscast, it says:
format.csv { send_data @products.to_csv }
Why don't you do that?
If that doesn't work, could you please try to collect your @books
object with the following code? I'm interested whether it will make a difference:
Book.where(:bookstore_id => @bookstore.id)
It shouldn't, but you seem to get an array of @books.each {|b| array << b.to_s}
somehow and I'm curious why.