marco-polo improves your Rails console prompt
MarcoPolo shows your app name and environment in your console prompt so you don't accidentally break production
Officially supporting IRB (standard rails console) and pry (via pry-rails gem).
Example:
$ rails console
Loading development environment (Rails 4.2.1)
agencyapp(dev)>
Related cards:
Tagaholic - Console Update With Your Editor
Rails’ script/console makes it easy to fetch, view and edit your database records. But can you edit those records as quickly as you edit code in your text editor? Riiight, like editing our database records in an editor is gonna happen? It already ...
Make your Rails console (and irb) output better readable
Pour color on your Rails console with awesome_print. Turn confusing long strings into formatted output. Have objects and classes laid out clearly whenever you need it.
Put `gem 'awesome_print', :g...
Your Rails sandbox console
Just found out about a great feature in Rails that seems to be around since Rails 2. Start a console with the --sandbox
(or -s
) parameter:
rails console --sandbox
All changes you make to the database will be rolled back on ...
Yarn: if integrity check won't let you start rails console
I ran into a situation in which I received the yarn integrity check warning when starting the rails console even though everything was up to date and correct versions in use.
TLDR: run spring stop
I tried starting the rails console without...
Rails: Encrypting your database information using Active Record Encryption
Since Rails 7 you are able to encrypt database information with Active Record. Using Active Record Encryption will store an attribute as string in the database. And uses JSON for seri...
Logging multiple lines in Rails without making filtering your logs difficult
Rails' default logger prefixes each log entry with timestamp and tags (like request ID).
For multi-line entries, only the first line is prefixed which can give you a hard time when grepping logs.
Example
Rails.logger.info(<<~TEXT)
...
Use non-ASCII characters on IRB and Rails consoles with RVM and Mac OS X
If you are using RVM on a Mac and cannot enter 8+ bit characters on an IRB or Rails console, you are missing the readline
package. You will need to re-install your Ruby to fix this:
rvm remove ree
rvm package install readline
rvm in...
console-for opens a Rails console remotely on a Capistrano deployment target
We're adding a script console-for
to open a remote Rails console with one command. Also have a look at shell-for
, which this script is rel...
Your database tables should always have timestamps
Whenever you create a table from a database migration, remember to add updated_at
and created_at
timestamps to that table. Without those timestamps, investigating future bug reports will be hell. Always have timestamps.
Adding timestamps ...
Rails console tricks
Also see the list of IRB commands.
Switching the context
Changes the "default receiver" of expressions. Can be used to simulate a "debugger situation" where you are "inside" an object. This is espe...