Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想捕捉在视图部分中发生的 Twitter::Error 并仍然加载页面。换句话说,我不希望 Twitter::Error 阻止页面加载。我只想不加载那个部分。
https://gist.github.com/scottmagdalein/903cd168ea4171365d51
您可以从错误中解救出来以允许您需要的东西:
def my_method begin # do some things rescue Twitter::Error flash[:notice] = 'oh dear!' end # any other view code end
您捕获错误,设置消息,然后继续查看您的视图。