Export to CSV

in Export to CSV, i have overall 2500 records, and while exporting it
takes long time to export all records, so, i have decided to export in
the form of 1st 50 students,and, 2nd 50 students,so on. I have tried
the below code. but it could able to fetch only 1st 50 students.

please, guide me how to solve the problem

def exportcsv

@student_count = Student.find(:all)
@count1 = @student_count.count
st_per_file = 50
count = 0
unless @count1==count
students = Student.find(:all, :order => ‘name’, :limit =>
st_per_file, :offset => (st_per_file*count))
count = count + 1

filename = ‘students.csv’
headers.merge!(
‘Content-Type’ => ‘text/csv’,
‘Content-Disposition’ => “attachment; filename=”#{filename}"",
‘Content-Transfer-Encoding’ => ‘binary’
)


end
end

Really? Two posts?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs