开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜