#48 Console Tricks (revised)
Jun 09, 2012 | 9 minutes |
Tools
Here you will learn how to get the most out of the Rails console. I will also demonstrate several utility gems and how to use them without adding them to the Gemfile.
- Download:
- source codeProject Files in Zip (46.7 KB)
- mp4Full Size H.264 Video (27 MB)
- m4vSmaller H.264 Video (11.5 MB)
- webmFull Size VP8 Video (10.8 MB)
- ogvFull Size Theora Video (23.5 MB)
Yeah, but what about Lion os, where I can found ~/.irbrc ???
touch ~/.irbrc
File does not exist, you have to create it ;)
Great as always. Thanks.
For people who are using unicode characters, there is a gem called "hirb-unicode" which alignes the table contents correct.
Btw.: I don't have the bundler issues (rvm / hirb-unicode). Not that I want to complain ;)
My fault. Already added the gem to the gemfile months ago :)
The bundler hack does not work for me, I have to add the gems to the gemfile.
The Textmate snippet for Sublime Text -
ty
A ton of useful information as usual :)
I use the ruby-debug gem and now debugger gem, which you recently covered in a revised episode. For a lone developer working by himself, being able to use the ruby-debug/debugger gem is an essential survival skill.
I was wondering if you use any techniques that are specifically applicable to debugging and finding what is not working faster? I haven't kept up with the Pry gem and tried to use it following your episode on it, but it was not a replacement for ruby-debug. Anything which helps find those pesky bugs faster would be super useful.
I prefer using an ide debugger, like the one in RubyMine. You can conveniently step through code and inspect variables. Super useful...
How'd you do that if you're using something like Vagrant (a virtual machine for development).
Trying to adapt the open a specific method's source at a given line number which Ryan demonstrates using TextMate to VIM. Here is my code in the .irbrc file:
Here is what I get when try to follow the number_to_currency example:
helper.v(:number_to_currency)
Vim: Warning: Output is not to a terminal
Any ideas anyone?
Thanks in advance.
Bharat
Try the following:
Remove the reload bits if you don't require them.
Oh and if you want it to work without rails:
Hey Thanks Robert. Works like a charm from within the Rails Console. I could not make it work in the plain irb outside of Rails. May be I am missing something?
The
y
method should still be there if yourequire 'yaml'
first.Weird, I get
On launch.
Hirb also renders Mongoid documents in a MySQL-like table!
replacement for 'rails dbconsole' for Mongoid:
http://crumbtrail.chesmart.in/post/1334264255/handy-bits-for-mongoid-with-rails-3
fancy_irb isn't working from the Console, I get:
However it works if I execute irb, how can I fix this?
Is any substitute for fancy_irb when im using pry instead of irb ??
I find that "reload!" is extremely useful in the rails console when doing development; it reloads your environment, so it should pick up any changes you make to your source files.
Methodfinder is great. So many times I run into this case!