Derek
Derek

Reputation: 12378

How to run rake task during rails initiation?

I have my own secret key generating script that I've placed in a rake command. I can execute this on its own without starting the rails server, but I want to incorporate this rake task into the rails server initiation so I don't need to call the rake task by itself anymore.

Where/How do I run this rake command such that it's part of the initiation process?

Upvotes: 1

Views: 313

Answers (1)

Tamer Shlash
Tamer Shlash

Reputation: 9523

If the secret key rake task doesn't have the environment dependency, you can just create a new initializer in config/initializers and name it secret_generate.rb for example, and in it write:

`rake your_task_name`

This will run your rake task on rails server initiation.

Upvotes: 1

Related Questions