link_to with :protocol isn't working

后端 未结 2 1144
面向向阳花
面向向阳花 2021-02-13 07:12

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 => \         


        
2条回答
  •  感情败类
    2021-02-13 08:08

    If you are using bartt-ssl_requirement rubygem in your app, you can use the ssl-url-helper to explicitly mention http or https protocol.

    Advantages:

    1. If you've disabled SSL check (in development environment), by following way: SslRequirement.disable_ssl_check = true, then passing :secure => true won't explicitly add https links to your view. This is not the case if you specify :protocol => 'https' and disable SSL check.

    2. Also, its not necessary to change line_items_path to line_items_url at each place.

提交回复
热议问题