Permalink
Browse files

fixed guard_entry method bugs submitted by Morgan, Nate and EDK

  • Loading branch information...
1 parent 4dd1c8e commit a0c1bbdd8ab230f9d633b3d10cbd80c10576371b @jeffp committed Oct 6, 2009
Showing with 28 additions and 16 deletions.
  1. +1 −1 README.rdoc
  2. +10 −6 app/controllers/generated_controller.rb
  3. +17 −9 lib/wizardly/wizard/configuration/methods.rb
View
2 README.rdoc
@@ -18,7 +18,7 @@ Examples
== Contributions
-Thanks for feedback from Roland Schulz, Steve Hoeksema, Morgan Christiansson, Jonathan Clarke
+Thanks for feedback from Roland Schulz, Steve Hoeksema, Morgan Christiansson, Jonathan Clarke, Nate Delage
== Description
View
16 app/controllers/generated_controller.rb
@@ -179,11 +179,15 @@ def check_progression
# for :form_data=>:session
def guard_entry
if (r = request.env['HTTP_REFERER'])
- h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path)
- return check_progression if (h[:controller]||'') == 'generated'
- self.initial_referer = h unless self.initial_referer
+ begin
+ h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get})
+ rescue
+ else
+ return check_progression if (h[:controller]||'') == 'generated'
+ self.initial_referer = h unless self.initial_referer
+ end
end
- # coming from outside the controller
+ # coming from outside the controller or no route for GET
if (params[:action] == 'init' || params[:action] == 'index')
return check_progression
@@ -330,9 +334,9 @@ def callback_performs_action?(methId)
cache = self.class.wizard_callbacks
return false if cache.include?(methId)
- begin
+ if self.respond_to?(methId, true)
self.send(methId)
- rescue NoMethodError
+ else
cache << methId
return false
end
View
26 lib/wizardly/wizard/configuration/methods.rb
@@ -221,11 +221,15 @@ def check_progression
# for :form_data=>:session
def guard_entry
if (r = request.env['HTTP_REFERER'])
- h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path)
- return check_progression if (h[:controller]||'') == '#{self.controller_name}'
- self.initial_referer = h unless self.initial_referer
+ begin
+ h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get})
+ rescue
+ else
+ return check_progression if (h[:controller]||'') == '#{self.controller_path}'
+ self.initial_referer = h unless self.initial_referer
+ end
end
- # coming from outside the controller
+ # coming from outside the controller or no route for GET
#{guard_line}
if (params[:action] == '#{first_page}' || params[:action] == 'index')
return check_progression
@@ -244,9 +248,13 @@ def guard_entry
# for :form_data=>:sandbox
def guard_entry
if (r = request.env['HTTP_REFERER'])
- h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path)
- return check_progression if (h[:controller]||'') == '#{self.controller_name}'
- self.initial_referer = h
+ begin
+ h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get})
+ rescue
+ else
+ return check_progression if (h[:controller]||'') == '#{self.controller_path}'
+ self.initial_referer = h
+ end
else
self.initial_referer = nil
end
@@ -395,9 +403,9 @@ def callback_performs_action?(methId)
cache = self.class.wizard_callbacks
return false if cache.include?(methId)
- begin
+ if self.respond_to?(methId, true)
self.send(methId)
- rescue NoMethodError
+ else
cache << methId
return false
end

0 comments on commit a0c1bbd

Please sign in to comment.