使用脚本/控制台时如何重新加载环境?

发布于 2024-09-03 06:39:26 字数 132 浏览 2 评论 0原文

我想我在 Ryan Bates 的一个截屏视频中看到过这样的场景,但我找不到。

我相信您可以在脚本/控制台中运行一个命令,它可以让您重新加载模型(如果您已进行更改),这样您就不必退出然后重新调用控制台。

有什么想法吗?

I think I have seen Ryan Bates do it one of his screencasts, but I can't find it.

I believe there is a command you can run while in script/console that lets you reload your models (if say you have made a change) so that you dont have to exit and then recall the console.

Any Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愚人国度 2024-09-10 06:39:26

只需使用:

reload!

但是,请注意,这不会反映控制台中已实例化的模型上的更改。要反映已实例化模型中的更改,您可以访问此答案

Just use:

reload!

However, do note that this won't reflect the changes on the models that are already instantiated in your console. To reflect changes in already instantiated models, you may visit this answer.

羁客 2024-09-10 06:39:26

如果您使用 rspec 使用

load 'some_class.rb'

If you are using rspec use

load 'some_class.rb'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文