我想做这样的事情
config.default_host = 'www.subdomain.example.com'
在我的一些配置文件中,这样object_url
帮手(ActionView::Helpers::UrlHelper
) 生成以以下内容开头的链接http://www.subdomain.example.com
我尝试搜索文档,但除了ActionMailer
文档和http://api.rubyonrails.org/classes/Rails/Configuration.html这对我来说没有用,因为我不知道该看哪个拍。有没有地方描述了Rails::Initializer.config的整个结构?
asset_host
不适用于网址
你需要覆盖default_url_options
在你的ApplicationController
(至少在 Rails 3 中)
http://edgeguides.rubyonrails.org/action_controller_overview.html#default-url-options
class ApplicationController < ActionController::Base
def default_url_options
if Rails.env.production?
{:host => "myproduction.com"}
else
{}
end
end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)