0

我使用名为 auto_html 的 gem 嵌入了 soundcloud URL。我的网站时不时地随机崩溃,出现一个错误,这似乎是由于 soundcloud 上的流量过多而导致的超时请求?有没有办法在请求超时并重新加载页面时忽略嵌入文件的代码行?

错误:

JSON::ParserError

ActionView::Template::Error (757: unexpected token at '<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

          We were unable to process your request in time - SoundCloud
          Yikes, we were unable to process your request in time.
          Please reload the page or try again in a moment.

视图中要忽略的代码:

41:        <% if micropost.url.include? 'soundcloud' %>
42:          <%= auto_html(micropost.url) {soundcloud}  %>
43:        <% end %> 
4

1 回答 1

0

I guess you can create a helper method that will "execute" the auto_html helper method and return its result. In this method you can surround the call with begin, rescue and on error you can return a js that will do a reload (window.location.href...).

I don't know if you can redirect through a helper method, if yes then it would be even easier.

于 2013-05-03T00:06:51.097 回答