def index
unless params['excel'].blank?
render_csv("patients-#{Time.now.strftime("%Y%m%d")}")
else
render
end
end
def render_csv(filename = nil)
filename ||= params[:action]
filename += '.csv'
if request.env['HTTP_USER_AGENT'] =~ /msie/i
headers['Pragma'] = 'public'
headers["Content-type"] = "text/plain"
headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'
headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""
headers['Expires'] = "0"
else
headers["Content-Type"] ||= 'text/csv'
headers["Content-Disposition"] = "attachment; filename=\"#{filename}\""
end
render :layout => false
end
I want it to use a different view and no layout, but I want to be able to reuse this function and not hard code a template… Any ideas?
(Right now I am getting html in my .csv file)
I ended up making a link and using