Ruby on rails 如何在我的视图中显示ActionView::Template::Error

Ruby on rails 如何在我的视图中显示ActionView::Template::Error,ruby-on-rails,ruby-on-rails-3,actionview,Ruby On Rails,Ruby On Rails 3,Actionview,我想在我的视图中显示来自任何ActionView::Template::error的错误消息 我的终端中只有这些错误消息,如: ActionView::Template::Error (No route matches {:controller=>"transactions", :action=>"download", :id=>nil}) 你试过这个吗 begin ... rescue Exception => ex @message = ex.message

我想在我的视图中显示来自任何
ActionView::Template::error
的错误消息

我的终端中只有这些错误消息,如:

ActionView::Template::Error (No route matches {:controller=>"transactions", :action=>"download", :id=>nil})
你试过这个吗

begin
  ...
rescue Exception => ex
  @message = ex.message
  render "error"
end
error是只包含一行的视图:error.html.erb

<%= @message %>


但这将在控制器中出现错误,我无法在我的视图中执行
开始救援
这应写入控制器中,如果遇到错误,控制器将呈现错误页面。错误发生在我视图中的
条件下,但我将尝试这样做,so simple=)谢谢,我相信如果在rails标记之间编写,这应该也适用于视图。