Beware old files which can cause strange errors

10 views
Skip to first unread message

Marcus Roberts

unread,
Apr 12, 2008, 3:29:19 AM4/12/08
to Phusion Passenger Discussions
If you're using source control properly, you probably don't have any
old files around anyway, but in one of my projects, as I migrated from
one architecture to another, I kept some of the old model and
controller files around as old_user.rb and old_session_controller.rb
for example. Passenger loads every *.rb file in the models and
controllers directory, so depending on the ordering of the filenames,
I was getting mysterious errors in the log from old code.

Once I cleared all the old_* files away, everything worked perfectly.

So I think the key is that Passenger acts a little differently in how
is loads classes, so make sure there's nothing in your folders that
can overwrite your current code.

Tamer Salama

unread,
Apr 12, 2008, 3:43:34 AM4/12/08
to phusion-...@googlegroups.com
I think this is a normal Rails behavior (not Passenger).

What errors were you getting?

--
Tamer Salama
http://tamersalama.com

Marcus Roberts

unread,
Apr 12, 2008, 4:41:26 AM4/12/08
to Phusion Passenger Discussions


On Apr 12, 8:43 am, "Tamer Salama" <tamerhelmysal...@gmail.com> wrote:
> I think this is a normal Rails behavior (not Passenger).
>
> What errors were you getting?
>

If I had two files in the controllers folder, one called
old_sessions_controller.rb and one called sessions_controller.rb, the
controller class defined in the old_ file was the one that was
answering requests. (I'm wondering if it's because old_session comes
before session alphabetically)

Running it under Mongrel, the controller in the non old_ file was the
code which was run.

It's bad practice to have these old_ files around of course, but it
caught me out as I was trying Passenger for the first time.


Jonathan Julian

unread,
Apr 14, 2008, 1:38:29 PM4/14/08
to Phusion Passenger Discussions
It's not normal Rails behaviour - try script/console with a syntax
error in a model file.

It looks like Passenger is pre-loading all files in the models dir
when the spawner starts up.

Hongli Lai

unread,
Apr 14, 2008, 3:53:49 PM4/14/08
to phusion-...@googlegroups.com
Jonathan Julian wrote:
> It's not normal Rails behaviour - try script/console with a syntax
> error in a model file.
>
> It looks like Passenger is pre-loading all files in the models dir
> when the spawner starts up.

This is correct. We do this to improve startup time, as well as to save
memory. Though the latter is only possible in combination with our
copy-on-write friendly Ruby branch, which will soon be released.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Reply all
Reply to author
Forward
0 new messages