# Misunderstanding init\_engine.rb?

**URL:** <https://www.ruby-forum.com/t/misunderstanding-init-engine-rb/95259>\
**Category:** Engines\
**Created:** [May 25, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/misunderstanding-init-engine-rb/95259 "2006-05-25T21:28:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [May 25, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/misunderstanding-init-engine-rb/95259/1 "2006-05-25T21:28:54Z")

</div>

(Sorry if this is not the right list – I tried posting to engine-  
developers, but got no response.)

It seems to me that the init\_engine.rb file must not be getting  
processed, or – just as likely – I’m misunderstanding something.

For example, in init\_engine.rb, I have:

module PSitsnotEngine  
module VERSION  
Major = 0 # change implies compatibility breaking with previous  
versions  
Minor = 1 # change implies backwards-compatible change to API  
Release = 0 # incremented with bug-fixes, updates, etc.  
end

# Configuration – can be overridden in environment.rb

config :max\_output\_size, 640  
config :max\_cache\_size, 1024  
config :cache\_file\_type, ‘png’  
end

Then, I use script/console:

> > PSitsnotEngine.class  
> > =\> Module
> 
> > PSitsnotEngine::VERSION.class  
> > NameError: uninitialized constant VERSION  
> > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > lib/active\_support/dependencies.rb:123:in `const\_missing’  
> > from (irb):2
> 
> > PSitsnotEngine.config :max\_output\_size  
> > =\> nil
> 
> > PSitsnotEngine::CONFIG  
> > =\> {}

What am I missing here? The “config” statements work fine if I put  
them in environment.rb.

```
				--Al Evans--
```

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [May 26, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/misunderstanding-init-engine-rb/95259/2 "2006-05-26T16:49:08Z")

</div>

Hi Al,

This is indeed the right place to post. First things first - what  
versions of Ruby, Rails and the Engines plugin are you using?

The next thing to do when debugging this kind of stuff is stick ‘puts’  
lines at the top of files and start script/console or the webrick  
server, so you can see what’s being loaded when. FYI, the file  
‘init\_engine.rb’ will get loaded when you call Engines.start  
:\<engine\_name\>.

- james

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [May 27, 2006, 12:02am UTC](https://www.ruby-forum.com/t/misunderstanding-init-engine-rb/95259/3 "2006-05-27T00:02:10Z")

</div>

On May 26, 2006, at 9:46 AM, James A. wrote:

> Hi Al,
> 
> This is indeed the right place to post. First things first - what  
> versions of Ruby, Rails and the Engines plugin are you using?

ruby 1.8.4, Rails 1.1.2, Engines 1.1.2

> The next thing to do when debugging this kind of stuff is stick ‘puts’  
> lines at the top of files and start script/console or the webrick  
> server, so you can see what’s being loaded when. FYI, the file  
> ‘init\_engine.rb’ will get loaded when you call Engines.start  
> :\<engine\_name\>.

(IN init\_engine.rb)  
puts “init\_engine.rb loaded”  
puts “PSitsnotEngine::VERSION::Minor is #  
{PSitsnotEngine::VERSION::Minor}”  
puts “PSitsnotEngine.config :max\_output\_size is #  
{PSitsnotEngine.config :max\_output\_size}”

alsmini:~/Development/RonRailsDev/psitsnot-engine al$ script/console  
Loading development environment.  
init\_engine.rb loaded  
PSitsnotEngine::VERSION::Minor is 1  
PSitsnotEngine.config :max\_output\_size is 640

So it looks good at this point. But then I type:

> > PSitsnotEngine::VERSION::Minor  
> > NameError: uninitialized constant VERSION  
> > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/  
> > lib/active\_support/dependencies.rb:123:in `const\_missing’  
> > from (irb):1
> 
> > PSitsnotEngine.config :max\_output\_size  
> > =\> nil

As you can see, it all disappeared. If I put the same initialization  
into environment.rb, it stays put.

Thanks in advance for any clues you can give me.

```
				--Al Evans--
```
