Dynamic Table Selection in Rails

I'm looking at various technologies in an effort to build a very flexible but also very simple application.

A requirement for the application is to take the database table name (or in this case a view) as a parameter. The database will be Oracle 10.2. The application will simply list (and paginate) records in a view that is composed from two tables. The tables contain information about files on the file system of the application server. (filename, path, title, subject, etc)

The requirement is important because it ensures that one web application can handle many customers. Customers are all inter- departmental within an organization and would not care if their data is inadvertently exposed by a mistyped URL, all of the data will be publicly available and not restricted.

As an example I'd like it to work something like this, the URL to a retrieve a given listing would be:

http://servername.domain/List/microgravity or http://servername.domain/List/ssme

The last bit of the path would be the database to use. From my very limited knowledge of Rails this would not be practical in Rails. What do you think?

Thanks, -Mark

I'm looking at various technologies in an effort to build a very flexible but also very simple application.

A requirement for the application is to take the database table name (or in this case a view) as a parameter. The database will be Oracle 10.2. The application will simply list (and paginate) records in a view that is composed from two tables. The tables contain information about files on the file system of the application server. (filename, path, title, subject, etc)

[...]

As an example I'd like it to work something like this, the URL to a retrieve a given listing would be:

http://servername.domain/List/microgravity or http://servername.domain/List/ssme

The last bit of the path would be the database to use. From my very limited knowledge of Rails this would not be practical in Rails. What do you think?

It's quite doable, and not too difficult. You can choose to do it with or without ActiveRecord. With AR, you'll need to dynamically create classes. That isn't all that difficult, but it can become a memory leak if you aren't careful. Without AR, you'll just connect to the DB directly and perform queries against it, displaying the result sets. It doesn't sound like you'll be treating the rows as models, so this may be appropriate.

For the routing, you just need '/List/:tablename' to map to a particular controller and action and use params[:tablename] in the action implementation.

Thanks, -Mark

--Greg