how to output the current protocol and url using rails?
I have a share dialog.
On dev it looks like:
http://xxxxxx.com/stuff
On prod:
https://yyyyyyyyyyy.com/stuff
What's the best rails way to output #Protocol# #URL#
And where can I set th开发者_运维知识库ese in rails? thanks
request.protocol
request.url
See the request object.
request object. you can use request.fullpath
API reference is here
Try adding the following to your development.rb file
Rails.application.routes.default_url_options[:protocol] = 'http'
and in production.rb file
Rails.application.routes.default_url_options[:protocol] = 'https'
Best way I found:
url_for(:only_path => false)
精彩评论