try this, it should work fine
def download
if @company.send(doc).exists?
data = open(@company.send(doc).expiring_url)
send_data data.read, :filename => "name.pdf", :type => data.content_type
else
respond_with_error(:not_found)
end
end