Dynamic Models and WordPress MU

Hi,

WordPress is a PHP-based blogging engine. The MU version supports
multiple blogs in the same database (as opposed to just one in the
basic WordPress app) I'm looking at writing some Rails-based admin
modules to interact with WordPress MU.

WordPress MU creates a separate set of tables for each blog. It does
this by using a master wp_blogs table and for each blog it creates a
set of tables named like:

wp_nn_posts
wp_nn_comments

The "nn" is the record id from the wp_blogs tables. So blog id of 1
generates:

wp_1_posts
wp_1_comments

What would be the best way to reference these models through
ActiveRecord?

Would it be as simple as creating 1 base set of models and then using
Model.table_name = "wp_1_posts" to point to the right tables when the
admin module is accessed? Is the table_name attribute safe to play
with in a multi-user environment? Is another way better suited to
this kind of access?

There are more tables than indicated above, I'm trying to keep this
post short :slight_smile: We're looking at potentially hosting 100's of blogs so
I don't think we want to create a distinct set of models for each.

Thanks for any advice,

Shawn