# ModRuby Init Handler

**URL:** <https://www.ruby-forum.com/t/modruby-init-handler/111191>\
**Category:** Ruby\
**Created:** [August 3, 2007, 6:14pm UTC](https://www.ruby-forum.com/t/modruby-init-handler/111191 "2007-08-03T18:14:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [August 3, 2007, 6:14pm UTC](https://www.ruby-forum.com/t/modruby-init-handler/111191/1 "2007-08-03T18:14:03Z")

</div>

Hello,

Apache 2.2.4  
Ruby 1.8.6  
mod\_ruby 1.2.6

I try to use RubyInitHandler:

# ========================= .htaccess

RubyRequire myhandlers.rb

\<Files \*.html\>  
SetHandler ruby-object

RubyInitHandler MyInitHandler.instance

# ========================== myhandlers.rb

require ‘singleton’

class MyInitHandler  
include Singleton

def init( r )  
raise ‘in init’  
end  
end

===============================

1. Method “init” of my handler was not be called. Why?
2. I try to write wrong class name for RubyInitHandler, and also no  
error:  
RubyInitHandler \_\_\_\_\_MyInitHandler.instance
3. RubyFixupHandler works! All is OK.

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [August 7, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/modruby-init-handler/111191/2 "2007-08-07T21:12:50Z")

</div>

Are you trying to run Ruby scripts on Apache ?  
You do not need mod\_ruby for that.  
All you need to do is, make some changes to your httpd.conf file. There  
are two ways to do that.

[http://httpd.apache.org/docs/1.3/misc/FAQ.html#CGIoutsideScriptAlias](http://httpd.apache.org/docs/1.3/misc/FAQ.html#CGIoutsideScriptAlias)

Vadim S. wrote:

> Hello,
> 
> Apache 2.2.4  
> Ruby 1.8.6  
> mod\_ruby 1.2.6
> 
> I try to use RubyInitHandler:
> 
> # ========================= .htaccess
> 
> RubyRequire myhandlers.rb
> 
> \<Files \*.html\>  
> SetHandler ruby-object
> 
> RubyInitHandler MyInitHandler.instance
> 
> # ========================== myhandlers.rb
> 
> require ‘singleton’
> 
> class MyInitHandler  
> include Singleton
> 
> def init( r )  
> raise ‘in init’  
> end  
> end
> 
> ===============================
> 
> 1. Method “init” of my handler was not be called. Why?
> 2. I try to write wrong class name for RubyInitHandler, and also no  
> error:  
> RubyInitHandler \_\_\_\_\_MyInitHandler.instance
> 3. RubyFixupHandler works! All is OK.
