带有 :protocol 的 link_to 不起作用 [英] link_to with :protocol isn't working

查看:48
本文介绍了带有 :protocol 的 link_to 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个使用 SSL 的链接.我正在使用此代码:

I want to have a link use SSL. I'm using this code:

<%= link_to "Buy now!", line_items_path(:thing_id => @thing), :method => :post, :protocol => "https", :only_path => false %>

由于某种原因,链接是用 http:// 而不是 https:// 生成的.

For some reason, the link is being generated with http:// instead of https://.

我使用的是 Rails 3.0.3.

I'm using Rails 3.0.3.

推荐答案

您必须将 :protocol 选项放在路径助手中:

You must put the :protocol option inside the path helper:

<%= link_to "Buy now!", line_items_url(:thing_id => @thing, :protocol => "https"), :method => :post %>

这篇关于带有 :protocol 的 link_to 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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