Tôi đang ở trên Rails 2.3.3 và tôi cần tạo một liên kết gửi yêu cầu đăng bài."render: nothing => true" trả về tệp plaintext trống?
tôi có một mà trông như thế này:
=link_to('Resend Email', {:controller => 'account', :action => 'resend_confirm_email' }, {:method => :post})
Mà làm cho hành vi JavaScript thích hợp vào liên kết:
<a href="/account/resend_confirm_email" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'EL9GYgLL6kdT/eIAzBritmB2OVZEXGRytPv3lcCdGhs='); f.appendChild(s);f.submit();return false;">Resend Email</a>'
controller action của tôi đang làm việc, và thiết lập để làm gì:
respond_to do |format|
format.all { render :nothing => true, :status => 200 }
end
Nhưng khi tôi nhấp vào liên kết, trình duyệt của tôi tải xuống tệp văn bản trống có tên "resend_confirm_ e-mail."
Điều gì mang lại?
Đối với đường ray 5, bạn có thể xem câu trả lời này https://stackoverflow.com/a/34688727/1770571 –
Đối với đường ray 5 bạn có thể xem câu trả lời này https: //stackoverflow.com/a/34688727/1770571 –