Can anyone tell me the "proper" way to extend a model provided by an
app engine (or any plugin for that matter).

I'm attempting to extend an app engine model by adding a
has_many :through. So I've got lib/myplugin_ext.rb and I'm requiring
that file in evironment.rb. My extension uses class_eval to add the
association.

This works fine in the console for viewing and adding stuff to the
has_many :through association, but in dev mode -- after the first
request -- if I try to add to the has_many :through, I get "TypeError:
Can't dup NilClass".

Because it works in the console but not in development mode after the
first request, this leads me to believe that it's a weird problem with
the reloader and how I'm extending the class. I've tried virtually
everything I can think of (aside from just moving the models from the
app engine into my app directory and modifying it there, which
works...), but I can't seem to avoid this error any other way.

I tried the "unloadable" suggestion posted here: http://strd6.com/?p=250

Adding unloadable to the app engine model only seemed to make the
situation worse. The app engine model gets reloaded without the
extension at all on subsequent requests.

I isolated the problem in a blank app and posted it here on github:
http://github.com/brentd/cantdupnilclass/tree/master

The stack trace is also available at that repo.

If I'm doin' it completely wrong, please tell me what would help. Much
appreciated :)

Brent

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to