How does one go about running code specifically after a console has loaded in Rails? All other answers and questions appear to revolve around running a hook at some point, but not necessarily after as I am seeking.
Desired Result:
> rails console
Loading development environment (Rails 5.1.1)
pry(main)>
Welcome
I have attempted to use both the console
hook and initializer
hook with no success. e.g.
Attempt 1:
# config/application.rb
console do
puts "Welcome"
end
Result:
> rails console
Welcome # Too early
Loading development environment (Rails 5.1.1)
pry(main)>
Attempt 2:
# config/application.rb
initializer "welcome", after: :disable_dependency_loading do |app|
puts "Welcome"
end
Result:
> rails console
Welcome # Too early
Loading development environment (Rails 5.1.1)
pry(main)>