Today I Learned

hashrocket A Hashrocket project

Rails::Application has a "console(&blk)" method

So you can run code only if you’re in a rails console:

# config/application.rb
module MyApplication
  class Application < Rails::Application
    console do
      `say -vkyoko こんにちは` if Rails.env.development?
    end
  end
  #...
end

Now I receive a greeting every time I run bin/rails console

Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.