`

rails程序部署90端口redirect_to默认跳转80端口奇怪问题

    博客分类:
  • RUBY
阅读更多
程序部署在90端口上时,new和edit方法执行后想跳转到index方法中。默认没有带90端口直接跳转到80默认端口了。

后台调用:
redirect_to_current_port("ac_roles")


方法处理:
def redirect_to_current_port(url)
     if request.host_with_port.include? ":"
       current_port= request.protocol  +  "#{request.host_with_port}/" + url
     else
       current_port= request.protocol + request.host_with_port+  ":#{$CURRENT_PORT.to_s[0..1]}/" + url
     end
     redirect_to current_port
   end


$CURRENT_PORT = YAML.load(ERB.new(IO.read("#{RAILS_ROOT}/config/mongrel_cluster.yml")).result)['port']
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics