When I try to run a script in the Rails Console, the message "Display all 746 posibilities?" runs strangely.

Asked 2 years ago, Updated 2 years ago, 93 views

Model.all.each do |x|
    if conditional expression
        x.stage=1
        x.save
    end
end

It's the same script as above. When enabled

irb(main):004:2> 
Display all 746 possibilities? (y or n)
!
!=
!~
<=>
==
===
=~

After performing the conditional expression, the script malfunctions with the above strange functionality.

Is there any way to give me an option on the console so that I don't get a Yes/No?

ruby-on-rails console

2022-09-21 15:23

1 Answers

It's a self-answer.

The cause was a problem caused by two tabs of indent in the script. If you double-click a tab on the terminal, functions like AutoComplete are executed, and the two tabs on the indent must have made the same behavior. All indentations are removed, so they work fine.

There's a reason why indentation is not a tab but a space.


2022-09-21 15:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.