Ruby on rails 为每个环境指定rails 4主机
使用Ruby on rails 为每个环境指定rails 4主机,ruby-on-rails,ruby,Ruby On Rails,Ruby,使用rails4.0.0和Ruby 2.0.0 我在rails控制台中查看我的\uURL和\uPaths,发现 2.0.0p247 :001 > app.host => "www.example.com" 2.0.0p247 :001 > app.root_url => "http://www.example.com/" 将主机设置为www.example.com只是rails c启动时的默认行为,还是在某个地方有设置此域的配置?如果是这样,如何设置每个环境的app
rails4.0.0
和Ruby 2.0.0
我在rails控制台中查看我的\uURL
和\uPaths
,发现
2.0.0p247 :001 > app.host
=> "www.example.com"
2.0.0p247 :001 > app.root_url
=> "http://www.example.com/"
将
主机设置为www.example.com
只是rails c
启动时的默认行为,还是在某个地方有设置此域的配置?如果是这样,如何设置每个环境的app.host
变量/config?在Rails 4控制台中,app.host
等访问“集成会话”:它似乎是控制台完全工作的占位符。显然,应用程序主机是不可配置的。看看铁路宝石
从v4.0.2开始执行:railties-4.0.2/lib/rails/console/app.rb
module Rails
module ConsoleMethods
def app(create=false)
@app_integration_instance = nil if create
@app_integration_instance ||= new_session do |sess|
sess.host! "www.example.com"
end
end
def new_session
app = Rails.application
session = ActionDispatch::Integration::Session.new(app)
yield session if block_given?
session
end
end
end
new\u session
方法允许选择主机。检查是否有帮助