开发者

Form_for with url, format and html options

I feel like im missing something simple here. I am using the form_for helper with an object. I specify the url, the format, and html method. Howe开发者_运维知识库ver, when rendered the url in the action attribute does not pick up the format. Here's my code:

=form_for(@site, url: compile_documents_path(@site), format: :csv, html: { method: :post}) do |f|

My controller is setup to respond to a csv format, and i simply call a to_csv method on the site object.

Any ideas as to why it's not working as expected.


Untested, but I think the format part should go into the url helper:

=form_for(@site, url: compile_documents_path(@site, format: :csv)) do |f|

Plus: I don't think you have to specify the method: :post part, as form_for will decide if it should use PUT or POST, based on whether @site is a new or an existing record.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜