Report abuse

1
2
3
4
5
6
7
8
9
10
# The following code will create a temporary file for say attaching a vcard file to email.The following code is dynamic to use ERB to create a template to create the file dynamically every time with the variable "telephone","location","email" which gets binded to the ERB file and is under scope
{
  telephone = "347-27456"
  location = "New Delhi"
  email = "xyz@gmail.com"
  vcard = ERB.new( File.open('address.vcard.erb' ){ |f| f.read } ).result( binding )
  f = File.new("temp_file.vcf","wb")
  f.puts vcard
  f.close
}