Module: Wicked::Controller::Concerns::RenderRedirect
- Extended by:
- ActiveSupport::Concern
- Included in:
- Wizard
- Defined in:
- lib/wicked/controller/concerns/render_redirect.rb
Instance Method Summary collapse
-
#finish_wizard_path(params = {}) ⇒ Object
TODO redirect to resource if one is passed to render_wizard.
- #process_resource!(resource, options = {}) ⇒ Object
- #redirect_to_finish_wizard(options = {}, params = {}) ⇒ Object
- #redirect_to_next(next_step, options = {}, params = {}) ⇒ Object
- #render_step(the_step, options = {}, params = {}) ⇒ Object
- #render_wizard(resource = nil, options = {}, params = {}) ⇒ Object
Instance Method Details
#finish_wizard_path(params = {}) ⇒ Object
TODO redirect to resource if one is passed to render_wizard
49 50 51 52 53 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 49 def finish_wizard_path(params = {}) url = '/' url = "#{url}?#{params.to_query}" unless params.blank? url end |
#process_resource!(resource, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 16 def process_resource!(resource, = {}) return unless resource if [:context] && resource.method(:save).arity >= 1 did_save = resource.save(context: [:context]) else did_save = resource.save end if did_save @skip_to ||= @next_step else @skip_to = nil end end |
#redirect_to_finish_wizard(options = {}, params = {}) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 55 def redirect_to_finish_wizard( = {}, params = {}) wicked_final_redirect_path = method(:finish_wizard_path).arity == 1 ? finish_wizard_path(params) : finish_wizard_path Rails.logger.debug("Wizard has finished, redirecting to finish_wizard_path: #{wicked_final_redirect_path.inspect}") # flash.keep is required for Rails 3 where a flash message is lost on a second redirect. flash.keep redirect_to wicked_final_redirect_path, end |
#redirect_to_next(next_step, options = {}, params = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 40 def redirect_to_next(next_step, = {}, params = {}) if next_step.nil? redirect_to_finish_wizard(, params) else redirect_to wizard_path(next_step, params), end end |
#render_step(the_step, options = {}, params = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 32 def render_step(the_step, = {}, params = {}) if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP redirect_to_finish_wizard , params else render the_step, end end |
#render_wizard(resource = nil, options = {}, params = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/wicked/controller/concerns/render_redirect.rb', line 5 def render_wizard(resource = nil, = {}, params = {}) process_resource!(resource, ) if @skip_to url_params = (@wicked_redirect_params || {}).merge(params) redirect_to wizard_path(@skip_to, url_params), else render_step(wizard_value(step), , params) end end |