Run the command when starting the Rails console

Is there a way to run a specific command when starting the rails console? I would like it to print whether I am connected to a remote or local database in BIG LETTERS! I do not mind writing my own method to determine this - I am just asking how to write to the console. I saw errors and warnings there.

For example: rails c prints Loading development environment (Rails 3.2.11) **USING REMOTE DATABASE** 1.9.3p125 :001 >

+8
ruby ruby-on-rails
source share
1 answer

You can write the ruby ​​code in the irb configuration irb . Edit the .irbrc file and add your ruby ​​code used to determine if you are connected to local or remote

 if defined? Rails //ruby code to find you connected to local or remote puts "USING REMOTE DATABASE...." end 
+3
source share

All Articles