Ruby Ruby2.7 irb paste long text error

FengJiaCheng · July 25, 2022 · Last by lisadsouza replied at May 21, 2024 · 284 hits

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

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

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

有谁遇到这个问题么?

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

Reply to femto

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

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

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

Our services are very affordable. You can easily get high quality escorts at any time. We provide the most beautiful independent girls we provide to the virgin Escort Service in Safdarjung as well as experienced girls who provide you romantic ways for your boring life.

You need to Sign in before reply, if you don't have an account, please Sign up first.