We’ve been busy on writing our own little engine, and we didn’t want to
put our engine’s model code in a lib or make it an abstract class, since
that isn’t very clean Of course, copying the model code completely
into
the application’s model is right out.
While thinking about this, it occurred to me that it’s very easy to let
Ruby
override the engine’s model:
class Foo < ActiveRecord::Base
def bar
qux()
end
end
This simply works. When you call Foo.new.blah(), it calls the engine’s
model’s qux() function. Perhaps this should be added to the
documentation as
this is a lot cleaner (IMHO) than the other two suggestions that are in
the
documentation?
Oddly enough, now it appears to work. I don’t know what changed,
unfortunately. We moved a lot of code around and made some major
changes, so it might have accidentally been fixed. Thanks for the
reply, anyway.
On Wed, Feb 21, 2007 at 03:56:27PM +0100, Peter B. wrote:
Hi there,
Oddly enough, now it appears to work. I don’t know what changed,
unfortunately. We moved a lot of code around and made some major
changes, so it might have accidentally been fixed. Thanks for the
reply, anyway.
Hmm, this should’ve been a reply to my other thread about testing.
Sorry for the noise.
I knew there had to be a better way. I just started monkeying around
with this myself but I’m pleased you beat me to it. You would think
that someone would have thought of this before though. Maybe there’s
some hidden risk that you and I are both missing?
in the class would hose things up? The idea below works great but I
have to
restart webbrick/mongrel every time I make a change. If I put in
“include
Reloadable” it seems to break everything.
-ben
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.