How to fix: irb / rails console randomly crashing
If your irb or rails console keeps randomly crashing and you can't figure out why then you can try to disable multi-line autocomplete.
Related cards:
How to fix: Pasting in IRB 1.2+ is very slow
IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting longer contents is incredibly slow. You can fix that by disabling said features. [1]
[Ruby 3.0.0-pre2 solved ...
Fix error: rails console No such file to load -- irb/encoding_aliases.rb (LoadError)
I got this error after upgrading Ruby from 2.4.5 to 2.6.4 when I opened the Rails console - rails server
still worked.
Running via Spring preloader in process 14679
Loading development environment (Rails 5.2.2.1)
Traceback (most recent call...
Ruby: How to measure code execution time in an IRB or Rails console
Paste this method into your console:
def time(&block) puts Benchmark.measure(&block) end
Now time { Some.lengthy_task }
will behave similar to the bash time
command. Of course you can do much more with the Benchmark object than just ...
Customize tokenization of the MySQL FULLTEXT parser
The way MySQL's FULLTEXT tokenizer splits text into word tokens might not always be what you need. E.g. it splits a word at period characters.
Since the tokenizer has near-zero configuration options (minimum word length and stopwords list), you n...
How to fix: "unexpected token" error for JSON.parse
When using the json gem, you might run into this error when using JSON.parse
:
>> json = 'foo'.to_json
>> JSON.parse(json)
JSON::ParserError: 757: unexpected token at '"foo"'
from /.../gems/json-...
How to make Rational#to_s return strings without denominator 1 again
The way Rational#to_s
works on Ruby has changed from Ruby 1.9 on. Here is how to get the old behavior back.
You may want this for things where Rationals are being used, like when subtracting Date
objects from one another.
What's happening?...
Rails: Fixing ETags that never match
Every Rails response has a default ETag
header. In theory this would enable caching for multiple requests to the same resource. Unfortunately the default ETags produced b...
Ruby and Rails deprecation warnings and how to fix them
Add deprecation warnings and their solution or link to available solutions.
Global access to Rake DSL methods is deprecated. Please include Rake::DSL into classes and modules which use the Rake DSL methods.
---------------------------------------...
How to fix: Font too small when reading e-mails in Thunderbird
In Thunderbird, you can set custom font faces and sizes for reading plain-text e-mails. However, Thunderbird sometimes "randomly" does not respect your choices.
This is actually not a bug, but a rather weird feature: Fonts are defined **per encod...
Upgrading Cucumber and Capybara to the latest versions available for Rails 2
Specify these gem versions in your Gemfile:
gem 'cucumber', '~> 1.3.0'
gem 'cucumber-rails', '= 0.3.2' # max version for Rails 2
gem 'capybara', '< 2' # capybara 2+ requires Rails 3
gem 'mime-types', '< 2' # dependeny of capybara
...