这个问题在这里已有答案:
Rails 3.2`link_to`(在电子邮件中)与`method :: put`仍然产生GET请求 2答案我正在使用Rails和ActionMailer发送电子邮件
= link_to "Change", update_url( id: @model.id, value1: "data1", :value2 => "data2"), :action => 'update', :method => :put在Rails视图中,上面的链接工作正常,它到了正确的位置=>更新,但当我将它集成到邮件/电子邮件中时,它会变为“新”。
请问为什么请提示?
This question already has an answer here:
Rails 3.2 `link_to` (in email) with `method: :put` still producing GET request 2 answersI am using Rails and ActionMailer to send emails
= link_to "Change", update_url( id: @model.id, value1: "data1", :value2 => "data2"), :action => 'update', :method => :putThe above link works fine when in Rails view and it goes to the right place => update, but it goes to "new" when I integrate it into mail/email.
Any tips on why please?
最满意答案
链接正在正确创建,但rails不显眼的javascript句柄实际上使链接执行put请求。 由于电子邮件中不存在此javascript,因此该链接只能发出get请求。
此电子邮件链接通常会链接到edit操作(带有get ),而不是直接执行更改。
The link is being created correctly, but rails unobtrusive javascript handles actually making the link do a put request. Since this javascript doesn't exist in the email, the link will only be able to make a get request.
This email link would more usually link to the edit action (with a get), not actually perform a change directly.
更多推荐
发布评论