我有一个方法,我已经开始在多个模型中使用 Webscraping,保存它的最佳位置在哪里?我应该把它放在application_controller,application_helper中吗?我不确定将它放在哪个好地方供多个模型使用它?
def self.retryable(options = {}, &block)
opts = { :tries => 1, :on => Exception }.merge(options)
retry_exception, retries = opts[:on], opts[:tries]
begin
return yield
rescue retry_exception
retry if (retries -= 1) > 0
end
yield
end