Skip to content

Commit

Permalink
Bug 526: handle routing errors with not_found
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Nov 8, 2009
1 parent 8f7b7fb commit 827c1f9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
11 changes: 9 additions & 2 deletions hobo/lib/hobo/controller.rb
Expand Up @@ -23,6 +23,7 @@ def included_in_class(klass)
Thread.current['Hobo.current_controller'] = nil # should avoid memory-leakage
end
@included_taglibs = []
rescue_from ActionController::RoutingError, :with => :not_found
end
Hobo::HoboHelper.add_to_controller(klass)
end
Expand Down Expand Up @@ -155,8 +156,14 @@ def request_no_cache?
request.env['HTTP_CACHE_CONTROL'] =~ /max-age=\s*0/
end

def not_found

def not_found(error)
if "not_found_response".in?(self.class.superclass.instance_methods)
super
elsif render_tag("not-found-page", {}, :status => 404)
# cool
else
render(:text => ht(:"hobo.messages.not_found", :default=>["The page you requested cannot be found."]) , :status => 404)
end
end

end
Expand Down
2 changes: 1 addition & 1 deletion hobo/lib/hobo/hobo_helper.rb
Expand Up @@ -45,7 +45,7 @@ def controller_for(obj)


def subsite
params[:controller].match(/([^\/]+)\//)._?[1]
params[:controller]._?.match(/([^\/]+)\//)._?[1]
end


Expand Down
11 changes: 0 additions & 11 deletions hobo/lib/hobo/model_controller.rb
Expand Up @@ -774,17 +774,6 @@ def permission_denied(error)
end


def not_found(error)
if "not_found_response".in?(self.class.superclass.instance_methods)
super
elsif render_tag("not-found-page", {}, :status => 404)
# cool
else
render(:text => ht(:"hobo.messages.not_found", :default=>["The page you requested cannot be found."]) , :status => 404)
end
end


def this
@this ||= (instance_variable_get("@#{model.name.underscore}") ||
instance_variable_get("@#{model.name.underscore.pluralize}"))
Expand Down
2 changes: 1 addition & 1 deletion hobo/taglibs/rapid_forms.dryml
Expand Up @@ -183,7 +183,7 @@ AJAX based submission can be enabled by simply adding an `update` attribute. e.g
page_path = if (request.post? || request.put?) && params[:page_path]
params[:page_path]
else
view_name.sub(Hobo::Dryml::EMPTY_PAGE, params[:action])
view_name.sub(Hobo::Dryml::EMPTY_PAGE, params[:action] || '')
end
page_path_hidden = hidden_field_tag("page_path", page_path)
end
Expand Down

0 comments on commit 827c1f9

Please sign in to comment.