当创建新资源并且需要进行一些冗长的处理以使资源准备就绪时,我该如何将该处理发送到后台,以便不会影响当前请求或其他流量到我的Web应用程序?
在我的模型中:
class User < ActiveRecord::Base
after_save :background_check
protected
def background_check
# check through a list of 10000000000001 mil different
# databases that takes approx one hour :)
if( check_for_record_in_www( self.username ) )
# code that is run after the 1 hour process is finished.
user.update_attribute( :has_record )
end
end
end