我应该如何构建我的 Rails 3 应用程序以在 Heroku 上进行 Beta 测试?
我正在深入研究 Ruby on Rails,并尝试从头开始构建一个基本的 Web 应用程序来学习该平台和相关技术。到目前为止,我只在本地计算机上运行它,但我想将其部署到免费的 Heroku 帐户,以开始熟悉在实时服务器上部署和测试应用程序。显然,我不希望该应用程序向任何人公开,因为它还远未完成,而且还没有准备好供公众使用。我想我想做的事情类似于封闭测试,但由于这是我第一次尝试,我不知道应该朝哪个方向来完成此任务。
我启用了用户帐户和身份验证。我可以做的一件事是扔出一个静态登录页面,显示该网站正在建设中,并且由于我有一个登录 URL,我可以将 before_filter
添加到我的所有控制器,以便只有我可以登录并访问该网站,但这感觉很黑客,并且不允许我正确测试应该公开的页面(因为它们是私有的)。我在这里至少有正确的想法吗?还是我的策略偏离了?
Heroku 是否有任何内置支持可以在站点准备好公开之前将其保持私有?
任何方向都会有所帮助,非常感谢!
I'm diving into Ruby on Rails and I'm trying to build a basic web app from scratch to learn the platform and associated technologies. So far, I only have it running on my local machine, but I'd like to get it deployed to a free Heroku account to start getting familiar with deployment and testing the app on a live server. Obviously I don't want the app to be publicly available to anyone since it's far from finished and simply not ready for public use. I suppose what I'm trying to do is similar to a closed beta test, but since this is my first go around, I have no idea which direction I should go to accomplish this.
I have user accounts and authentication enabled. One thing I could do is toss up a static landing page that shows the site is under construction, and since I have a login URL, I could just add before_filter
's to all my controllers so that only I can login and access the site, but that feels hackish and doesn't let me properly test the pages that should be public (because they're private). Do I at least have the right idea here? Or is my strategy way off?
Does Heroku have any built in support for keeping sites private until they're ready to go public?
Any direction would help, thank you so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,如果您使用 heroku 生成的子域之一(例如“pretty-flower-99.heroku.com”),那么不太可能有人会偶然发现您的应用程序。或者您可以自己指定一个非常模糊的域/子域。
之后,最简单的事情可能是将 http 基本身份验证添加到您的应用程序控制器并在 before_filter 中运行它。像这样的东西:
这将为您提供一个基于旧式浏览器的用户名和密码对话框。如果您想在任何地方跳过此操作,只需在该控制器中运行skip_before_filter即可。
First, if you're using one of heroku's generated subdomains (like "pretty-flower-99.heroku.com") it's not likely anyone will stumble upon your app. Or you can specify a very obscure domain/subdomain yourself.
After that, the easiest thing to do is probably add http basic authentication to your application controller and run it in a before_filter. Something like this:
This will give you an old-school browser-based username and password dialog. If there are any places you want to skip this, just run a skip_before_filter in that controller.
如果在某个时候您希望允许多个用户进行 Beta 测试而不必强制执行 http 基本身份验证,则可以在 User 模型上设置状态属性。这样,您仍然可以让人们注册,然后通过 Heroku 控制台或您自己的管理页面批准他们。
新的 Rails Enums 功能使它变得非常简单。
创建迁移:
包括枚举状态和之前的操作:
#live?方法是通过枚举免费提供给您的。
http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html
If at some point you want to allow multiple users to beta test without having to enforce http basic auth, you can set a status attribute on the User model. This way you can still have people sign up, then through Heroku console or your own admin page approve them.
The new Rails Enums feature makes it really easy.
Create a migration:
Include the enum status and a before action:
The #live? method is given to you free with Enums.
http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html