From: Jan Provaznik jprovazn@redhat.com
* html_error_page chose layout by @layout, but @layout is nil when error occurs (for example in controller) and then popup-error.rhtml template is used (this template should be used for ajax-requests, shouldn't be?) -> request.xhr? is used instead of @layout * when @layout was set, html_error_page set only layout and not template, so error wasn't displayed -> added simple layout/error.rhtml * passing of title and errmsg is now done with :locals, passing with @title and @errmsg doesn't work, if TemplateError occurs (for example use of undefined variable in template) --- src/app/controllers/application_controller.rb | 10 +++++----- src/app/views/layouts/error.rhtml | 4 ++++ src/app/views/layouts/popup-error.rhtml | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/app/views/layouts/error.rhtml
diff --git a/src/app/controllers/application_controller.rb b/src/app/controllers/application_controller.rb index a563d57..0bc3ca7 100644 --- a/src/app/controllers/application_controller.rb +++ b/src/app/controllers/application_controller.rb @@ -111,12 +111,12 @@ class ApplicationController < ActionController::Base end
def html_error_page(title, msg) - @title = title - @errmsg = msg - if @layout - render :layout => 'aggregator' + if request.xhr? + render :template => 'layouts/popup-error', :layout => 'popup', + :locals => {:title => title, :errmsg => msg} else - render :template => 'layouts/popup-error', :layout => 'popup' + render :template => 'layouts/error', :layout => 'aggregator', + :locals => {:title => title, :errmsg => msg} end end
diff --git a/src/app/views/layouts/error.rhtml b/src/app/views/layouts/error.rhtml new file mode 100644 index 0000000..094c13a --- /dev/null +++ b/src/app/views/layouts/error.rhtml @@ -0,0 +1,4 @@ +<%- content_for :title do -%> + <%= title %> +<%- end -%> +<%= errmsg %> diff --git a/src/app/views/layouts/popup-error.rhtml b/src/app/views/layouts/popup-error.rhtml index 8e58a31..094c13a 100644 --- a/src/app/views/layouts/popup-error.rhtml +++ b/src/app/views/layouts/popup-error.rhtml @@ -1,4 +1,4 @@ <%- content_for :title do -%> - <%= @title %> + <%= title %> <%- end -%> -<%= @errmsg %> +<%= errmsg %>