Reputation: 13425
Trying to use the form_tag helper in rails to submit to an SSL address. Currently, my code looks like this:
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>
That is of course, not a valid or worthwhile result. How can I make the form tag helper render out an https action path?
Thanks.
Upvotes: 4
Views: 3053
Reputation: 13425
It turns out that I was using the wrong syntax.
Instead of
form_tag(form_action_path, :protocol => 'https')
I needed
form_tag(form_action_url(:protocol => 'https'))
The difference being, apparently, that form_action_path generates something like "/path/to/action" and form_action_url generates "http://url.com/path/to/action."
Upvotes: 2
Reputation: 33954
You can use something like SSL_Requirement with your create/update actions. It seems SSL_Requirement is older (not that it needs to be updated, it's not terribly complicated), but there may be a newer gem/plugin that people prefer now.
Upvotes: 0