Read file into array

A

Anil Bhat

On the Internet.



May be the following code will help you:
def member_data
member = Member.find:)all)
stream_csv do |csv|
csv << ["First Name","Last Name","Email"]
member.each do |u|
csv << [u.first_name,u.last_name,u.email]
end
end
end

Explanation: Member is the model name. First name, last name and email
are the fields shown while downloading CSV.
Following code to be written in rhtml file:
<%= link_to 'download', :controller => 'reports', :action =>
'member_data' %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top