Created
May 13, 2020 15:26
-
-
Save bkeepers/27e9e087835cf4799937ac1476e3c923 to your computer and use it in GitHub Desktop.
Add methods to `rails console`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SailboatGuide | |
class Application < Rails::Application | |
console do | |
require 'console_helpers' | |
TOPLEVEL_BINDING.eval('self').extend ConsoleHelpers | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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