Ruby Ruby2.7 irb paste long text error

FengJiaCheng · 2022年07月25日 · 最后由 yasminansari 回复于 2024年03月26日 · 275 次阅读

问题描述:rails console 进行调试时,粘贴大段代码报错,并且 rails console 被中断。

最近老项目进行版本升级,升级到 Ruby2.7.6 + Rails6.0.2。

随之遇到 rails console 下,粘贴大段代码很慢,容易出错。找了很多解决方案,大部分建议用 --nomultiline 方式去提速。通过这一方式确实解决了粘贴慢的问题,但是粘贴大段代码 (600 行),仍然会出错,并退出 rails console 模式。

有谁遇到这个问题么?

为什么需要粘贴大段代码?写个 rake task 不行么? 或者写个文件,console 里头 require 就行

femto 回复

比如线上调试,发现依赖的 Class A 有一个 bug,调整代码后需要线上验证。

感觉还是很奇怪的需求。有多种方式解决,你能写文件系统就写个文件 require, 要不然建个 model DynamicCode,然后后台系统弄个 textarea 填代码, 然后 console 里头 eval DynamicCode.first.code

一个思路,没试过:tmp 目录下建个临时文件,往里面写临时代码,在 console 里面读该文件再 eval

Escorts Service Near The Lalit New Delhi offer their clients a range of contact options. This can include in person meetings, over the phone calls and internet contacts as well as providing massages and erotic entertainment Escorts near The Lalit Hotel are known for their knowledge and professionalism, meeting all of their clientele's needs in order to ensure complete satisfaction Are You Searching for Available to meet you wherever it suits best or meet you in your hotel room - these beautiful call girls promise an unforgettable experience that you can reach them any time via Escort Number.

需要 登录 后方可回复, 如果你还没有账号请 注册新账号