[英]How to run rake task during rails initiation?
I have my own secret key
generating script that I've placed in a rake
command. 我有自己的
secret key
生成脚本,该脚本已放置在rake
命令中。 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. 我可以自行执行此操作而无需启动
rails server
,但是我想将此rake
任务合并到rails server
启动中,因此不再需要rake
调用rake
任务。
Where/How do I run this rake
command such that it's part of the initiation process? 在哪里/如何运行此
rake
命令,使其成为启动过程的一部分?
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: 如果
secret key
耙任务不依赖于environment
,则可以在config/initializers
创建一个新的初始化config/initializers
并将其命名为secret_generate.rb
,例如:
`rake your_task_name`
This will run your rake task on rails server initiation. 这将在Rails服务器启动时运行rake任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.