Skip to content

Instantly share code, notes, and snippets.

@bkeepers
Created May 13, 2020 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkeepers/27e9e087835cf4799937ac1476e3c923 to your computer and use it in GitHub Desktop.
Save bkeepers/27e9e087835cf4799937ac1476e3c923 to your computer and use it in GitHub Desktop.
Add methods to `rails console`
module SailboatGuide
class Application < Rails::Application
console do
require 'console_helpers'
TOPLEVEL_BINDING.eval('self').extend ConsoleHelpers
end
end
end
# Helper methods for `rails console`
#
#. $ rails console
# >> s = slug 'pacific-seacraft/25'
# => #<Sailboat:0x00007fa2a4339480 ...>
#
module ConsoleHelpers
def slug(path)
Slug.by_path(path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment