Seeking Advice on Pattern for Multi-Organization Application

I am the developer of FreeMIS - an Open Source management information
system for schools. It currently holds the data for one school - so
different schools host different instances of FreeMIS.

I would like to expand the domain of a single instance of FreeMIS, so
that it covers all the schools in an education authority. THis will
enable me to implement authority-wide functionality.

Is there a standard pattern for this kind of extension? As I see it,
everything that is in the database will need also to belong to a school,
and when someone logs in they will only see the data relevant to their
school (unless they are education authority managers who will have their
own interface).

Any advice on how to implement this in the DRYest, most Rails-esque way
will be most gratefully received :slight_smile:

Robert J.

On Jul 1, 2006, at 18:25 , Robert J. wrote:

I would like to expand the domain of a single instance of FreeMIS, so
that it covers all the schools in an education authority. THis will
enable me to implement authority-wide functionality.

Sounds like what you want is an Authority model that
has_many :schools. I don’t think you want a separate database for
each school.

Michael G.
grzm seespotcode net

On Jul 1, 2006, at 2:25 AM, Robert J. wrote:

school,


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

You should have a look at the acount_location plugin. Its built for
this situation. It allows you to have accounts keyed off of
subdomains. like foo.example.com and bar.example.com. This way you
have an Account model and you use a before filter on every request
that takes the subdomain and finds the account that matches that
subdomain. Then you scope your queries to the account model.

-Ezra

On 7/2/06, Ezra Z. [email protected] wrote:

enable me to implement authority-wide functionality.
way

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

With the account_location plugin, does it automatically setup the
required
DNS entries? Or does an app need to look after this itself?
This is a very weak point for me, and has basically stopped me from
looking
at it too closely.

Dan

On Jul 1, 2006, at 6:30 PM, Daniel N wrote:

their


that takes the subdomain and finds the account that matches that
required DNS entries? Or does an app need to look after this
itself?
This is a very weak point for me, and has basically stopped me from
looking at it too closely.

Dan

Dan-

Yeah you have to set up a wildcard dns entry for your domain in

order to use this in production. But you can set up aliases in /etc/
hosts for when you are developing locally.

for local stuff ad a line like this to your /etc/hosts file:

127.0.0.1 advisrdev.org ezmobius.advisrdev.org demo.advisrdev.org

That gives me a few subdomains and a main domain to work with locally.

-Ezra

On 7/2/06, Ezra Z. [email protected] wrote:

school,
Robert J.
subdomains. like foo.example.com and bar.example.com. This way you

Dan-

-Ezra

Thanx for the response, but I’m afraid I’m a bit thick with this stuff.
I
can see what you’ve done in the /etc/hosts file wrt local requests, is
it
enough to add to the hosts file on the server in a live app for external
users to have their browsers do the right thing or does it need to
update a
dns server?

Basecamp seems to have their accounts available on subdomains
immediatley
when you sign up so I don’t imagine that they have to propergate this
change
though the net DNS system.

Is there anywhere that gives a fairly in-depth explaination or tutorial
that’s not quite as dry as a DNS spec?

Cheers
Dan

Thanx for any help

On Jul 1, 2006, at 6:53 PM, Daniel N wrote:

On Jul 1, 2006, at 2:25 AM, Robert J. wrote:
will

own interface).
Rails mailing list

from looking at it too closely.
for local stuff ad a line like this to your /etc/hosts file:
requests, is it enough to add to the hosts file on the server in a
Cheers
Dan

Thanx for any help

Dan-

Yeah you need to set up what's called a wildcard dns A record. This

looks like *.mydomain.com. What dns server are you using? Here is a
nice tutorial for bind, not rails specific but it should help anyway.

-Ezra

Ezra Z. wrote:

On Jul 1, 2006, at 2:25 AM, Robert J. wrote:

school,


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

You should have a look at the acount_location plugin. Its built for
this situation. It allows you to have accounts keyed off of
subdomains. like foo.example.com and bar.example.com. This way you
have an Account model and you use a before filter on every request
that takes the subdomain and finds the account that matches that
subdomain. Then you scope your queries to the account model.

-Ezra

Thanks for this (and for the other advice by other people) - this looks
like just what I need. The scoping of my queries to the account model
is going to take a while, but I know where I’m heading now.

Cheers,

Robert J.

On 7/2/06, Ezra Z. [email protected] wrote:

different schools host different instances of FreeMIS.
and when someone logs in they will only see the data relevant to

have an Account model and you use a before filter on every request

-Ezra
though the net DNS system.
Dan-

Yeah you need to set up what’s called a wildcard dns A record. This looks
like *.mydomain.com. What dns server are you using? Here is a nice tutorial
for bind, not rails specific but it should help anyway.

Wildcard DNS and Sub Domains | Matt Mullenweg

-Ezra

Ezra,

Thanx for the pointer. Being on windows it took me a while to get it
going… Eventually got it with the treewalk dns server.

Cheers
Dan