# Error mailer type control

**URL:** <https://www.ruby-forum.com/t/error-mailer-type-control/183421>\
**Category:** Rails\
**Created:** [February 13, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/error-mailer-type-control/183421 "2010-02-13T18:22:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 13, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/error-mailer-type-control/183421/1 "2010-02-13T18:22:49Z")

</div>

I am really not interested in getting error mails for crap like people  
scanning to see if I have some outdated version of phpmyadmin,  
roundcube, etc… the typical stuff hackers are will look for.

So within my application controller before it sends me an e-mail, I want  
to search to see if it’s a valid ‘controller’ that’s being requested  
before it actually sends me an error e-mail.

Thus I need something like…

if [LIST\_OF\_MY\_CONTROLLERS].include?(params[:action])

how do I get a list of my controllers?

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 3:23am UTC](https://www.ruby-forum.com/t/error-mailer-type-control/183421/2 "2010-02-14T03:23:01Z")

</div>

Craig W. wrote:

> I am really not interested in getting error mails for crap like people  
> scanning to see if I have some outdated version of phpmyadmin,  
> roundcube, etc… the typical stuff hackers are will look for.
> 
> So within my application controller before it sends me an e-mail, I want  
> to search to see if it’s a valid ‘controller’ that’s being requested  
> before it actually sends me an error e-mail.
> 
> Thus I need something like…
> 
> if [LIST\_OF\_MY\_CONTROLLERS].include?(params[:action])
> 
> how do I get a list of my controllers?
> 
> Craig
> 
> –  
> This message has been scanned for viruses and  
> dangerous content by MailScanner, and is  
> believed to be clean.

I don’t know of a good way to list of all your app’s controllers (you  
_could_ search for all Constants that descend from  
ApplicationController, but that seems prettttty grody). I’m _assuming_  
the emails are being sent from a rescue\_from or somesuch similar in your  
ApplicationController… would it work for your requirements to instead  
just create a catchall route and then send a 404 error/page?

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 6:18am UTC](https://www.ruby-forum.com/t/error-mailer-type-control/183421/3 "2010-02-14T06:18:34Z")

</div>

On Sun, 2010-02-14 at 03:23 +0100, Paul H. wrote:

> > if [LIST\_OF\_MY\_CONTROLLERS].include?(params[:action])
> > 
> > how do I get a list of my controllers?

> I don’t know of a good way to list of all your app’s controllers (you  
> _could_ search for all Constants that descend from  
> ApplicationController, but that seems prettttty grody). I’m _assuming_  
> the emails are being sent from a rescue\_from or somesuch similar in your  
> ApplicationController… would it work for your requirements to instead  
> just create a catchall route and then send a 404 error/page?

* * *

well I am certainly trying to deal with a ‘rescue\_from’.

In essence, all the various crap that people scan web servers in hopes  
of finding exploitable software for are generating 404 errors…that’s  
to be expected.

I just don’t want to see an e-mail if the URL’s they are requesting  
aren’t a controller in my application.

Obviously I can provide a defined list of my controllers to this but  
that is rather analog and rails should be able to give me a list of my  
controllers or an array that I can flatten.

Thanks

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 7:34am UTC](https://www.ruby-forum.com/t/error-mailer-type-control/183421/4 "2010-02-14T07:34:04Z")

</div>

On Sat, 2010-02-13 at 22:16 -0700, Craig W. wrote:

> > > Thus I need something like…  
> > > ApplicationController… would it work for your requirements to instead
> 
> Obviously I can provide a defined list of my controllers to this but  
> that is rather analog and rails should be able to give me a list of my  
> controllers or an array that I can flatten.

* * *

this gets me awfully close…

@conts = []  
controllers = Dir.new("#{RAILS\_ROOT}/app/controllers").entries  
controllers.each do |controller|  
if controller =~ /\_controller/ and not controller.index(".swp") then  
cont =  
controller.gsub(".rb~","").gsub(".rb","").gsub("\_controller","")  
@conts \<\< [cont]  
end  
end  
and I can flatten @conts at that point and I could spend the time to  
toss .svn out but for now, I’m good.

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.
