如何更改默认的“www.example.com"?用于在 Rails 中测试的域? [英] How do I change the default "www.example.com" domain for testing in rails?

查看:22
本文介绍了如何更改默认的“www.example.com"?用于在 Rails 中测试的域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Rails 应用程序,它的行为取决于它所访问的域(例如 www.myapp.com 调用的方式与 user.myapp.com 不同).在生产使用中,这一切正常,但我的测试代码总是看到www.example.com"的主机名.

I have a rails application which acts differently depending on what domain it's accessed at (for example www.myapp.com will invoke differently to user.myapp.com). In production use this all works fine but my test code always sees a hostname of "www.example.com".

有没有一种干净的方式让测试指定它假装访问的主机名?

Is there a clean way of having a test specify the hostname it's pretending to access?

推荐答案

@request.host = 'user.myapp.com'

这篇关于如何更改默认的“www.example.com"?用于在 Rails 中测试的域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆