module DelayedAction
Constants
- VERSION
Public Instance Methods
delayed_action_dispatch()
click to toggle source
# File lib/delayed_action/delayed_action_concern.rb, line 44 def delayed_action_dispatch return if params[:force] if params[:delayed_uuid] delayed_action_view else delayed_action_queue end end
delayed_action_queue()
click to toggle source
# File lib/delayed_action/delayed_action_concern.rb, line 14 def delayed_action_queue params_to_copy = ["SCRIPT_NAME", "PATH_INFO", "QUERY_STRING", "REQUEST_METHOD", "HTTP_COOKIE", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT", "REMOTE_ADDR", "SERVER_PROTOCOL", "HTTP_HOST", "HTTP_USER_AGENT" , "HTTP_VERSION", "HTTP_X_FORWARDED_PROTO"] request_env = {} params_to_copy.each do |p| request_env[p] = request.env[p] end result = DelayedAction::DelayedActionResult.create request_env: request_env.to_json job = DelayedActionActiveJob.perform_later result if request.fullpath.include?("?") path = "#{request.fullpath}&delayed_uuid=#{result.uuid}" else path = "#{request.fullpath}?delayed_uuid=#{result.uuid}" end redirect_to path end
delayed_action_view()
click to toggle source
# File lib/delayed_action/delayed_action_concern.rb, line 34 def delayed_action_view # unwrap the job, get the results and view it here result = DelayedAction::DelayedActionResult.find_by_uuid(params[:delayed_uuid]) if result.result.blank? render html: "<html><head><title>Loading</title><meta http-equiv='refresh' content='5'></head><body>Loading, this page will refresh in 5 seconds. Or, <a href='#{request.fullpath}'>refresh this page</a> for results...</body></html>".html_safe else render body: "#{result.result}", content_type: result.content_type end end