If you modify code in the Rails console will that affect a server running in parallel?

橙三吉。 提交于 2019-12-24 10:35:35

问题


Is it possible to run "rails console" in one shell and then "rails server" in another and then have code changes in the console permeate to the running application? Presumably this isn't possible, but I'd just like to check if there is a way.

Edit: Both are running in the same environment. And by code changes I mean changes to class definitions (e.g. rewriting a method on the Post model).


回答1:


If you modify any data, that will indeed permeate. However modifications to methods done on the fly by opening classes and "monkey-patching" them will not affect your running application - unless your modified method modifies data.

However, it is always advisable to run the console in a different environment with different data to avoid harming a running application.




回答2:


If you are changing data in your console IN THE SAME ENVIRONMENT then it will be changed in the browser.



来源:https://stackoverflow.com/questions/5804941/if-you-modify-code-in-the-rails-console-will-that-affect-a-server-running-in-par

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!