Behaviors suddenly missing from select field

Hi all. I’ve been using Radiant for about 3 months now. Today I noticed
that when editing/creating pages in Radiant, my behavior select field is
empty.

Running:

Behavior.find_all.map { |s| s.registered_id }

From the console returns all my Behaviors, and my actual Ruby files are
there, they’re just not being seen when creating/editing pages.

What’s really bizarre is that the production version of this same web
site behaves as it should. I checked out a fresh copy from subversion,
dropped and migrated my database back and I’m having the same problems.

Oh, my co-worker just informed me that the filters are also missing. I
put a little debug line inside registerable.rb (a scary file imo), and
when starting console I now see…

BASE >>> TextFilter (Module)
BASE >>> Behavior (Module)

Yeah. I’m at a total loss. We haven’t edited anything with Radiant in a
couple weeks, which also means I don’t know how long the problem has
been going on. =(

Any ideas?

Okay well, on a hunch, I changed require_dependency filter and
require_dependency_behavior in environment.rb to simply require, and it
works again.

What does require_dependency do? I remember reading about it on the
Rails blog many months ago, but I’ve never understood it. =(

Anywho… hope that helps anyone else having the same problem. WEIRD.

Nevermind, it doesn’t work. The behaviors show up on the first page view
after restarted the server, but never again. This sucks.

FUN! I changed my environment file to use 1.1.6 and it works again.

I triple-checked my production environment and it’s using 1.2.1.

The biggest difference I see is that I’m on Windows (cry) and my
production server runs Linux.

No, the biggest difference is that one is in production mode and one is
in development mode.

The reloading code in rails changed between 1.1 and 1.2 - reloading
doesn’t occur in production mode.

Radiant comes pinned to Rails 1.1.6 for a reason.

Dan.

FUN! I changed my environment file to use 1.1.6 and it works again.

I triple-checked my production environment and it’s using 1.2.1.

The biggest difference I see is that I’m on Windows (cry) and my
production server runs Linux.

I guess the big test will be to check it on Mac (happy dance) when I get
home.

Daniel S. wrote:

No, the biggest difference is that one is in production mode and one is
in development mode.

The reloading code in rails changed between 1.1 and 1.2 - reloading
doesn’t occur in production mode.

Radiant comes pinned to Rails 1.1.6 for a reason.

I see. When you say 1.2 doesn’t reload, what do you mean? Why does
not reloading make Radiant work, but reloading breaks it?

Either way, thanks for answering, I feel better knowing someone else has
come across this issue.

  • Daniel

Nay… Switching into production mode doesn’t work either.

I dunno why it works on the production server. Weird. Oh well, 1.1.6 for
now.

Daniel S. wrote:

I haven’t come across your specific issue, but knowing the radiant and
rails codebases, I’m making a guess as to a possible cause.

Your knowledge exceeds mine. :slight_smile:

Also, the mental branch doesn’t have behaviours, it has extensions, so
the answer to ‘Do your behaviors load correctly under Mental and Rails
1.2.1?’ is no, but my extensions do. Have a look through the mailing
list archive for more information about porting behaviours to extensions
if you want to go down that path.

Ah, sweet. Thanks so much.

I see. When you say 1.2 doesn’t reload, what do you mean? Why does
not reloading make Radiant work, but reloading breaks it?

During initialization, the Behaviour class is loaded and all the
subclasses also get loaded. When a subclass is loaded, it registers
itself with the parent class.

What I think is happening is that the Behaviour class is getting
reloaded (and thus clearing the references to the subclasses), but the
subclasses are not reloaded, and thus don’t register themselves.

Either way, thanks for answering, I feel better knowing
someone else has
come across this issue.

I haven’t come across your specific issue, but knowing the radiant and
rails codebases, I’m making a guess as to a possible cause.

If it’s not working after switching to production and your production.rb
has cache_classes set to true, then I don’t think I know what your issue
is.

Also, the mental branch doesn’t have behaviours, it has extensions, so
the answer to ‘Do your behaviors load correctly under Mental and Rails
1.2.1?’ is no, but my extensions do. Have a look through the mailing
list archive for more information about porting behaviours to extensions
if you want to go down that path.

Dan.

Daniel S. wrote:

Just had a thought. If your problem is due to reloading, you might want
to add specific ‘require’ statements for behaviour.rb and all your
behaviours into your environment.rb. That should prevent reloading.

I’m still not sure why we want to prevent reloading, but sure enough,
adding require ‘behavior’ in environment.rb fixes it.

Thanks again.

Just had a thought. If your problem is due to reloading, you might want
to add specific ‘require’ statements for behaviour.rb and all your
behaviours into your environment.rb. That should prevent reloading.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs