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 => \
You must put the :protocol option inside the path helper:
<%= link_to "Buy now!", line_items_url(:thing_id => @thing, :protocol => "https"), :method => :post %>
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:
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.
Also, its not necessary to change line_items_path
to line_items_url
at each place.