Trevor Oke

3737844653

Programming Rails With Script/Console

I’m completely enamoured of script/console. It makes working on rails so much easier. Fr’instance, I blew up a migration just recently and had to get rid of a rogue table. Just open the console and:

1
2
irb ActiveRecord::Base.connection
tables drop_table "rogue_table" tables

Another fr’instance. When I’m learning the interface for a new class, I often have to refer to it a few times. The consle along with some meta=programming goodness make this a snap. So, to find all methods with “tag” in it:

1
MyClass.methods.sort.grep(/tag/)

That’s it.

Nice.