Familiarize quickly in new code with this trick
Here’s a quick and nifty little trick that comes in extremely handy in a lot of situations, but particularly when dealing with an unfamiliar codebase, such as at a new job or working with a previously unused external gem.In the rails console, enter:
ls Model
and it will show all the class and instance methods, as well as associations and a bunch of other cool stuff for that model.
I’ve begun using this in place of these two:
Model.methods
Model.new.methods
Not only because it’s simpler with less typing but it else ends up being much easier to read.