[英]How do you redefine a method like handle_asynchronously from delayed_jobs gem?
I'm trying to call the handle_asynchronously method only in production mode (I don't want it to be used in development mode). 我试图仅在生产模式下调用handle_asynchronously方法(我不希望在开发模式下使用它)。
Here's what I want to do: 这是我想做的:
def some_action_here
puts "Some text here"
end
handle_production_asynchronously :some_action_here
I have something like this in an config/initializers file: 我在config / initializers文件中有这样的内容:
module Patch
def handle_production_asynchronously(method, opts = {})
Rails.env == "production" ? delay.method : method # Probably incorrect. What do I put here?
end
end
Module.send(:include,Patch)
What should I place in the initializers in the line above to execute the methods correctly? 为了正确执行方法,我应该在上一行的初始化器中放置什么?
This worked for me: 这对我有用:
module Patch
def handle_production_asynchronously(method, opts = {})
handle_asynchronously method if Rails.env == "production"
end
end
Module.send(:include,Patch)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.