开发者

dynamic rails host name for routes

开发者 https://www.devze.com 2023-03-10 18:44 出处:网络
I\'m doing this in application controller: before_filter :set_app_host def set_app_host Rails.application.routes.default_url_options[:host] = \"some url\"

I'm doing this in application controller:

before_filter :set_app_host

def set_app_host
  Rails.application.routes.default_url_options[:host] = "some url"
end

This is to have a dynamic host name that can show up in link_to helper method. However this is not working, and the origina开发者_如何学JAVAl host name is showing instead. Any ideas?


In application_controller.rb

def default_url_options(options = nil)
  { :host => "example.com" }
end

From: http://edgeguides.rubyonrails.org/action_controller_overview.html#default_url_options

0

精彩评论

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

关注公众号