Skip to content

Commit

Permalink
Fixed edge case for routes being matched falsely and trying to instan…
Browse files Browse the repository at this point in the history
…tiate a non-existent controller.
  • Loading branch information
mtodd committed Apr 15, 2008
1 parent 8bb36aa commit ef07eea
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/halcyon/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,23 @@ def call(env)
#
# Returns (String|Array|Hash):body
def dispatch(env)
route = env['halcyon.route']
# make sure that the right controller/action is called based on the route
controller = case route[:controller]
when NilClass
# default to the Application controller
::Application.new(env)
when String
# pulled from URL, so camelize (from merb/core_ext) and symbolize first
Object.const_get(route[:controller].camel_case.to_sym).new(env)
end

begin
route = env['halcyon.route']
# make sure that the right controller/action is called based on the route
controller = case route[:controller]
when NilClass
# default to the Application controller
::Application.new(env)
when String
# pulled from URL, so camelize (from merb/core_ext) and symbolize first
Object.const_get(route[:controller].camel_case.to_sym).new(env)
end

controller.send((route[:action] || 'default').to_sym)
rescue NoMethodError => e
raise NotFound.new
rescue NameError => e
raise NotFound.new
end
end

Expand Down

0 comments on commit ef07eea

Please sign in to comment.