Added EmailsDownload controller and routes

Removed original method to return emails file from Newsletters controller and NewsletterZip class, included `rubyzip` gem that's no longer necessary.
This commit is contained in:
María Checa
2018-02-15 16:23:23 +01:00
committed by Bertocq
parent 1c653a7096
commit cb15a2e25b
5 changed files with 22 additions and 32 deletions

View File

@@ -1,25 +0,0 @@
require 'zip'
class NewsletterZip
attr_accessor :filename
def initialize(filename)
@filename = filename
end
def emails
User.newsletter.pluck(:email).join("\n")
end
def path
Rails.root + "/tmp/#{filename}.zip"
end
def create
Zip::File.open(path, Zip::File::CREATE) do |zipfile|
zipfile.get_output_stream("#{filename}.txt") do |file|
file.write emails
end
end
end
end