Forum: Ruby on Rails Suppress Routing Errors for Missing Static Files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hunter H. (Guest)
on 2007-01-18 20:16
(Received via mailing list)
Hello,

I'd like to know how I can suppress errors in the logs for routing
errors for missing files.

For instance, something like this:

[ERROR] application#index (ActionController::RoutingError) "no route
found to match \"/release/record_cover/192/small/646.jpg\" with
{:method=>:get}"

This is because a file is missing that is referenced on the page. We
have other methods to catch this and it is just cluttering up the
Rails log (and sending a ton of exception emails!) so I'd like to
disable them.

These are being reported at log level 'info'.

Thanks,
Hunter
Stephan W. (Guest)
on 2007-01-18 21:37
Hunter H. wrote:
> Hello,
>
> I'd like to know how I can suppress errors in the logs for routing
> errors for missing files.
>
> For instance, something like this:
>
> [ERROR] application#index (ActionController::RoutingError) "no route
> found to match \"/release/record_cover/192/small/646.jpg\" with
> {:method=>:get}"
>
> This is because a file is missing that is referenced on the page. We
> have other methods to catch this and it is just cluttering up the

What are these other methods?

You could have rescue_action_in_public(exception) check

      ActionController::UnknownController === exception ||
ActionController::UnknownAction === exception

and produce an error page, and have your own logging message (or none if
preferred).

Stephan

> Rails log (and sending a ton of exception emails!) so I'd like to
> disable them.
>
> These are being reported at log level 'info'.
>
> Thanks,
> Hunter
Stephan W. (Guest)
on 2007-01-18 22:23
Stephan W. wrote:
> Hunter H. wrote:
>> Hello,
>>
>> I'd like to know how I can suppress errors in the logs for routing
>> errors for missing files.
>>
>> For instance, something like this:
>>
>> [ERROR] application#index (ActionController::RoutingError) "no route
>> found to match \"/release/record_cover/192/small/646.jpg\" with
>> {:method=>:get}"
>>
>> This is because a file is missing that is referenced on the page. We
>> have other methods to catch this and it is just cluttering up the
>
> What are these other methods?
>
> You could have rescue_action_in_public(exception) check
>
>       ActionController::UnknownController === exception ||
> ActionController::UnknownAction === exception


I forgot -- plus, set the last entry in config/routes.rb like this.

 map.catchall '*all', :controller => 'some_controller', :action =>
'not_found'

with this not_found method in your "some_controller"

 def not_found
    log_info("Page not found: #{request.env['REQUEST_URI']}")
    @page_title = "Page not found"
    render :action => 'no_such_page', :layout=>'external', :status =>
404
  end

The not_found rhtml gives useful error information, as usual.

But you seem to have your own method, that's why I asked.


Stephan


>
> and produce an error page, and have your own logging message (or none if
> preferred).
>
> Stephan
>
>> Rails log (and sending a ton of exception emails!) so I'd like to
>> disable them.
>>
>> These are being reported at log level 'info'.
>>
>> Thanks,
>> Hunter
This topic is locked and can not be replied to.