Benjamin Curtis

Speculations on Web Development

Extending a Model From an Engine in Your Rails App

| Comments

While working on the Rails 3 upgrade of the SaaS Rails Kit (which is available for customers, BTW), I moved most of the guts of the Kit into a plugin (engine) to make it easier to integrate into pre-existing apps. Then, as I was working on integrating the Kit into a client app, I ran into a situation where I wanted to extend one of the models provided in the plugin in the app, since this was a project-specific tweak. I mixed together a couple of suggestions that I found on there on the internets to come up with this:

That is added to config/initializers, and it simply adds a couple of scopes to the model that this project needed (but that I’m not sure other RailsKit customers would care about).

Does that look like the best approach? Or is there a better way to extend models that are defined in a plugin?