Thursday, May 26, 2011

[Rails] generate xml file to download it

hi
i want to do a button_to to generate a xml file with all users i ahve
in the DB.
in the view i do:
<%= button_to "generate xml", :action => "create_file" %>
in the controller :
def create_file
@users = User.find(:all)
if File.exist?("/home/delmed/Bureau/users.xml")
file = File.open("/home/delmed/Bureau/users.xml","a+")
else
file = File.new('/home/delmed/Bureau/users.xml','a+')
end
@user.each do |user|
file.puts "aa"
end
file.close
end

when i click the button nothing happen and i have any no error !!!
then its possible on click it build a window to allow to choose the
dirictory to save the file?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate