Change protocol to https in all rails helpers

后端 未结 9 1593
情书的邮戳
情书的邮戳 2020-12-10 12:55

Rails 3.1+ I want my url helpers to use the https protocol without having to specify it in every helper I call. After searching around I\'ve found various ways but none work

9条回答
  •  眼角桃花
    2020-12-10 13:17

    You can add this code to ApplicationController

      def default_url_options(options={})
        options.merge(protocol: :https)
      end
    

    You can also check out to Getting Rails URL helpers to automatically output https urls

提交回复
热议问题