如何排除“提交”领域从铁路后有效载荷? [英] How to exclude "commit" field from rails post payload?

查看:150
本文介绍了如何排除“提交”领域从铁路后有效载荷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将数据发布到一个非常精美的OAuth 1.0外部端点,该端点除了有效负载中的特定字段之外不能有任何其他的



我想将此端点公开给用户通过按钮点击 - 所以我目前有一个窗体中的字段设置(使用 form_tag ),但我也有一个 submit_tag 在表单内部允许用户点击它并执行POST。



不幸的是,这个 submit_tag 生成一个类型为< input name =committype =submitvalue =Claim> 的输入字段, c $ c> commit = Claim ,这会中断端点。



有没有什么方法可以在rails中使用表单来将数据发送到不包括 commit = Claim 字段(它存在是提交表单的按钮的结果)?



<如果没有,最好的方法是什么?不幸的是我不能在幕后发布,因为它执行的是我需要用户关注的重定向。

解决方案

基本上,您需要摆脱输入按钮的名称属性。试试这个:

  submit_tagClaim,name:


I am POSTing data to a very finnicky OAuth 1.0 external endpoint that cannot have any except very specific fields in the payload

I want to expose this endpoint to the user via a button click -- so i currently have the fields setup in a form (using form_tag) but I also have a submit_tag inside the form to allow the user to click it and perform the POST.

Unfortunately the existence of this submit_tag generates an input field of type <input name="commit" type="submit" value="Claim"> and this ends up inside the payload as commit=Claim, this breaks the endpoint.

Is there any way of using a form in rails to POST data to an external endpoint WITHOUT including the commit=Claim field (which exists are a result of the button for submitting the form) ?

If not, what's the best way to do this? Unfortunately I can't post behind the scenes, as it performs a redirect that I need the user to follow.

解决方案

Basically, you need to get rid of the name attribute of your input button. Try this:

submit_tag "Claim", name: ""

这篇关于如何排除“提交”领域从铁路后有效载荷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆