# Behaviors suddenly missing from select field

**URL:** <https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183>\
**Category:** Radiant CMS\
**Created:** [February 2, 2007, 3:02am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183 "2007-02-02T03:02:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 3:02am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/1 "2007-02-02T03:02:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 3:25am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/2 "2007-02-02T03:25:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 3:41am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/3 "2007-02-02T03:41:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 4:22am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/4 "2007-02-02T04:22:45Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 3:57am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/5 "2007-02-02T03:57:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 4:33am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/6 "2007-02-02T04:33:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 4:35am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/7 "2007-02-02T04:35:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 6:56am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/8 "2007-02-02T06:56:42Z")

</div>

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. 🙂

> 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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 4:47am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/9 "2007-02-02T04:47:48Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/10 "2007-02-02T21:06:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [February 2, 2007, 7:40am UTC](https://www.ruby-forum.com/t/behaviors-suddenly-missing-from-select-field/84183/11 "2007-02-02T07:40:55Z")

</div>

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.
