Change protocol to https in all rails helpers

后端 未结 9 1612
情书的邮戳
情书的邮戳 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条回答
  •  猫巷女王i
    2020-12-10 13:20

    For a rails 5.2.0 RESTAPI App the following worked:

    In each environment file as necessary ie config/environments/test.rb

      Rails.application.routes.default_url_options[:protocol] = 'https'
    
    

    Controller code:

     Rails.application.routes.url_helpers.url_for(uploaded_file)
    

提交回复
热议问题