Rails: Force a form tag to use an HTTPS action

Trying to use form_tag helper on rails to send to SSL address. Currently my code is as follows:

form_tag(form_action_path) do
# This spits out:
<form action="form_action_path" method="post">

If I try this:

form_tag(form_action_path, :protocol => 'https', :only_path => false)
# It spits out:
<form action="form_action_path" method="post" protocol="https" only_path="false>

This, of course, is not a valid or worthwhile result. How can I make the form helper handler an https tag?

Thank.

+3
source share
2 answers

Turns out I used the wrong syntax.

Instead

form_tag(form_action_path, :protocol => 'https')

I need

form_tag(form_action_url(:protocol => 'https'))

The difference seems to be that form_action_path generates something like "/ path / to / action" and form_action_url generates "http://url.com/path/to/action."

+2
source

- SSL_Requirement /. , SSL_Requirement ( , , ), gem/plugin, .

0

All Articles