Q:

Advice on Modular Design in Rails App

I have an app that will have 3 modules, each created in its own Engine, namely:

Administration
Address Book
Calendar

In the Administration module, an admin user will be able to add, edit and delete other users. Each of these users will also have some generic functionality, like a log of all their actions on the app, and user rights per module.
In the Address Book module a user will have many Contacts. In the Calendar module a user will have many Events.
I would like to create the a separate User gem/module that is shared across all Engines, but I'm not sure how to deal with the relationships/models that are specific to each Engine. I have thought of extending the User module in each Engine, to include the specific relationships, but then I need to call its method using the Engine's User model instead of the Main App's User model (e.g. I have to do AddressBook::User.contacts instead of just User.contacts).
Is this my only option or am I missing something fundamental?
Any advice around this would be appreciated.

A:

Rails engines have the option of an isolated namespace, which works as you describe with AddressBook:User.contacts, but it isn't always best to use it. Without it you can define a User model in the app and in each engine, extend that model as needed. E.g. in the app:
class User < ActiveRecord::Base
  def embiggen
    self.bigness *= 2
  end
end

... and in the engine:
class User
  has_many :contacts
end

Then you always call User and don't have to add an Engine::User prefix. 

