私は Rails 2.3.3 を使用しており、投稿リクエストを送信するリンクを作成する必要があります。
次のようなものがあります。
= link_to('Resend Email',
{:controller => 'account', :action => 'resend_confirm_email'},
{:method => :post} )
これにより、リンク上で適切な JavaScript の動作が行われます。
<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>'
私のコントローラーアクションは機能しており、何もレンダリングしないように設定されています:
respond_to do |format|
format.all { render :nothing => true, :status => 200 }
end
しかし、リンクをクリックすると、ブラウザが「resend_confirm_email」という名前の空のテキスト ファイルをダウンロードします。
何を与える?