Hi there,

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:

In RAILS_ROOT/app/models/foo.rb:

require RAILS_ROOT + "/vendor/plugins/my_engine/app/models/foo"

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?

Regards,
Peter Bex
Solide ICT - http://www.solide-ict.nl
_______________________________________________
engine-developers mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org

Reply via email to