Module: SimpleWorkflow::Controller
Instance Method Summary
collapse
Methods included from Detour
#pop_detour, #reset_workflow, #store_detour_in_session
Instance Method Details
#back(response_status_and_flash) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/simple_workflow/controller.rb', line 33
def back(response_status_and_flash)
return false if session[:detours].nil?
detour = pop_detour(session)
post = detour.delete(:request_method) == :post
if post
set_flash(response_status_and_flash)
redirect_to_post(detour)
else
redirect_to detour, response_status_and_flash
end
true
end
|
#back_or_redirect_to(options = {}, response_status_and_flash = {}) ⇒ Object
46
47
48
|
# File 'lib/simple_workflow/controller.rb', line 46
def back_or_redirect_to(options = {}, response_status_and_flash = {})
back(response_status_and_flash) or redirect_to(options, response_status_and_flash)
end
|
#detour_to(options) ⇒ Object
Like ActionController::Base#redirect_to, but stores the location we come from, enabling returning here later.
7
8
9
10
|
# File 'lib/simple_workflow/controller.rb', line 7
def detour_to(options)
store_detour(params)
redirect_to(options)
end
|
#redirect_to_post(options) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/simple_workflow/controller.rb', line 65
def redirect_to_post(options)
url = url_for options
render :text => "<html>\n<body onload=\"document.getElementById('form').submit()\">\n <form id=\"form\" action=\"\#{url}\" method=\"POST\">\n </form>\n</body>\n</html>\n", :layout => false
end
|
#rjs_detour_to(options) ⇒ Object
12
13
14
15
|
# File 'lib/simple_workflow/controller.rb', line 12
def rjs_detour_to(options)
store_detour(params, request.post?)
rjs_redirect_to(options)
end
|
#rjs_redirect_to(options) ⇒ Object
17
18
19
20
|
# File 'lib/simple_workflow/controller.rb', line 17
def rjs_redirect_to(options)
@options = options
render :template => 'redirect', :layout => false, :formats => :js
end
|
#store_detour(options, post = false) ⇒ Object
22
23
24
25
26
|
# File 'lib/simple_workflow/controller.rb', line 22
def store_detour(options, post = false)
options = options.dup.permit!.to_h if options.is_a?(ActionController::Parameters)
options[:request_method] = :post if post
store_detour_in_session(session, options)
end
|
#store_detour_from_params ⇒ Object
28
29
|
# File 'lib/simple_workflow/controller.rb', line 28
def store_detour_from_params
end
|