Rails 应用程序 +缓存和环境模式
我刚刚完成 Rackspace 云服务器的设置,以托管我将使用 Ruby on Rails 构建的网站。我已经安装了最新版本的 Apache、Rails 和 Passenger(尽管说实话,我不太确定 Passenger 能给我带来什么)-(我刚刚检查过,Passenger 没有出现在 gem 列表中,但是它存在于启用 mods 中)。
我已经设置好了一切,并且可以使用适当的控制器和视图获得简单的路线。
我遇到的问题是,我只能在重新启动 Apache 后看到视图的更改,所以我假设正在进行某种缓存。我已经遵循了一些关于如何确保我在开发模式下运行的提示,但似乎没有任何效果。我已在 Apache 配置文件以及 Rails 应用程序的environment.rb 文件中放置了一条语句。
1) 如何查看我当前处于哪种模式? 2)如何将其更改为我需要的内容?
另外,我找到的很多答案都假设您正在脚本/控制台模式下运行应用程序。我通过 ssh 直接在服务器上工作,而且我从来没有必要使用脚本/控制台打开我的 Rails 应用程序。它就在那里并运行。
谢谢
更新:如果我在视图中打印 Rails.env,它会列出生产。如果我在命令行上启动 Rails 控制台并打印出 Rails.env,它会列出开发。
I just finished setting up a Rackspace Cloud Server to host a website I'm going to build using Ruby on Rails. I've installed the latest versions of Apache, Rails, and Passenger (although to be honest, I'm not quite sure what Passenger gets me) - (I just checked, and Passenger doesn't come up in a gem list, but it is present in mods-enabled).
I've got everything set up, and I can get simple routes working with the appropriate controllers and views.
The problem I'm having is that it I can only see changes to a view after restarting Apache, so I assume some sort of caching is going on. I've followed several tips on SO for how to make sure I'm running in development mode, but nothing seems to work. I've placed a statement in my Apache config file, as well as in my Rails app's environment.rb file.
1) How can I see which mode I'm currently in?
2) How do I change it to whatever I need it to be?
Also, a lot of answers I'm finding are presuming that you're running your app in script/console mode. I'm working directly on the server via ssh, and I haven't ever had to turn my rails app on using script/console. It's just there and running.
Thanks
Update: If I print out Rails.env in a view, it lists production. If I fire up rails console on the command line, and print out Rails.env, it lists development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不看你如何设置环境的情况下,这是我能给你的最好建议。
编辑此文件后,您必须重新启动 Apache。
Without seeing how you set the environment, this is the best advice I can give you.
After you edit this file you must restart Apache.