rails 5 run script only after server start
The config.ru
file is only used by web servers and not loaded by the console script, rake tasks or even your test suite. What you put there is only executed when a server instance launches.
Web servers themselves have also ways to do this. When you use Puma for instance, there are hooks like on_worker_boot
or after_worker_boot
, which may come to help (http://www.rubydoc.info/github/puma/puma/Puma/Configuration/DSL).
However, I'd recommend integrating this into your deployed server environment and out of the Rails app.
How to use Rails Console after I run rails server
After you run "rails s" open a new tab in the terminal (make sure that it is the same directory) and run rails console. The database it will be referring to in the console is the one being run by rails s.
How to start rails server?
In a Rails 2.3 app it is just ./script/server start
Related Topics
Why Is Devise Not Displaying Authentication Errors on Sign in Page
Capistrano 3 Execute Within a Directory
Connecting Using Https to a Server with a Certificate Signed by a Ca I Created
Using Ruby and Net-Ssh, How to Authenticate Using the Key_Data Parameter with Net::Ssh.Start
Ruby If .. Elsif .. Else on a Single Line
How Are Array.Each and Array.Map Different
How to Get My Aws Lambda to Access Gems Stored in Vendor/Bundle
Using Yield Inside Define_Method in Ruby
How to Create Md5 Hash with Hmac Module in Ruby
Check If a File Exists Using a Wildcard
Ruby Array of Hash. Group_By and Modify in One Line
How to Run Phantomjs on Heroku