Sometimes you might want to create aliases or functions for your rails console or irb. To do it you just need to create or edit ~/.irbrc
# ~/.irbrc
# If the command already exists and you want to create an alias for it
alias q exit
# Usage: q
# Create a class that contains methods that do work.
class SwissKnife
def list_tables
ActiveRecord::Base.connection.tables
end
end
# Usage: SwissKnife.list_tables
# OR If you want to create a base level method / command that does a few things at once you create a method on the kernel module.
# ** Note this can be UNSAFE if you overwrite any of the kernels methods
class Kernel
def tables
ActiveRecord::Base.connection.tables
end
end
# Usage: tables
Related External Links: