私はたくさんの写真を持っていますが、時々 1 つか 2 つは正しくアクセスできません。空白のスポットを挿入する代わりに、エラーをキャプチャして何も入れないようにしたいと思います。
エラー:
Rendered /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
html.erb でテストするにはどうすればよいですか?
<ul>
<% @photos.each do |photo| %>
<% if [HOW DO I TEST IT HERE?] %> //if no error
<li style="float: left;">
<%= link_to image_tag(photo.image.url(:thumb)), photo %>
</li>
<% else %> //if it errors that it can't access the file
// put nothing
<% end %>
<% end %>
</ul>
また、なぜそれが呼ばれる/にあるのrescues/layout
ですか? エラーは によって処理されていると思いましたが、logger
これは違いますか?
完全なトレース:
`Started GET "/system/images/13/thumb/f838fe117a5a1f03ff5d2056d026d61a.jpg?1358062373" for 127.0.0.1 at 2013-01-14 00:19:19 -0500
ActionController::RoutingError (No route matches [GET] "/system/images/13/thumb/f838fe117a5a1f03ff5d2056d026d61a.jpg"):
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.3) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.3) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.3) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.3) lib/rack/handler/webrick.rb:59:in `service'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)`