# How does Basecamp 'scope' distinct users in a monolithic dat

**URL:** <https://www.ruby-forum.com/t/how-does-basecamp-scope-distinct-users-in-a-monolithic-dat/89662>\
**Category:** Rails\
**Created:** [March 22, 2007, 12:32am UTC](https://www.ruby-forum.com/t/how-does-basecamp-scope-distinct-users-in-a-monolithic-dat/89662 "2007-03-22T00:32:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bravedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@bravedave](https://www.ruby-forum.com/u/bravedave)\
**Post date:** [March 22, 2007, 12:32am UTC](https://www.ruby-forum.com/t/how-does-basecamp-scope-distinct-users-in-a-monolithic-dat/89662/1 "2007-03-22T00:32:02Z")

</div>

I’m hoping to find someone who realizes the implications of this  
design strategy. I am attempting to build an application that access a  
common monolithic database but each user has a ‘scope’ so they only  
see their data…  
My strategy is to create an http request that looks like  
project.controller.action.keyvalue and pass this throughout the  
application. The “Project” term is used to describe a distinct data  
scope that one user or a group would maintain.  
I expect we’d make http calls like http:  
\project.controller.action.keyvalue and database calls like:  
link\_to: #{table.row.columname}  
:Project =\> project  
:Controller=\>controller  
:Action=\> action  
:Id =\> id

The patriarch of all RonR programs written by DHH (Basecamp) must  
utilize a strategy similar to this as they are running the same  
generic program, but accessing distinct data from one monolithic  
database.  
When Basecamp passes an http: request it’s got to hold inside this  
package the group database, user, controller, action and value. Does  
anyone know the basic architecture of how this is accomplished?  
I found one clue to this question today when looking at the the  
ActionPack API and in it, DHH wrote:

Routing makes pretty urls incredibly easy  
map.connect ‘clients/:client\_name/:project\_name/:controller/:action’

Accessing /clients/37signals/basecamp/project/dash calls  
ProjectController#dash with  
{ “client\_name” =\> “37signals”, “project\_name” =\> “basecamp” } in  
params[:params]

From that URL, you can rewrite the redirect in a number of ways:

redirect\_to(:action =\> “edit”) =\>  
/clients/37signals/basecamp/project/dash

redirect\_to(:client\_name =\> “nextangle”, :project\_name =\> “rails”)  
=\>  
/clients/nextangle/rails/project/dash

I am willing to pay for someone to teach me how this is done.

Thank you,  
David  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![bravedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@bravedave](https://www.ruby-forum.com/u/bravedave)\
**Post date:** [March 22, 2007, 12:56am UTC](https://www.ruby-forum.com/t/how-does-basecamp-scope-distinct-users-in-a-monolithic-dat/89662/2 "2007-03-22T00:56:04Z")

</div>

hi dave,

my apologies if i misunderstood your question, but if you’re asking  
about the routing, you can set up a route like so:

```
map.connect 'projects/:project_id/:controller/:action/:id'

```

and when you use link\_to, you only have to specify :project\_id on the  
link that takes them into the project; subsequently, omitted  
:project\_id and :controller default to the current one. so once in the  
widget controller for project 42, you can make links like:

link\_to @widget.name , :action =\> “show”, :id =\> @widget

which will create a link to: /projects/42/widget/show/23

of course on each request you need to validate that the user is a  
member of the project and that the data they are asking for belongs to  
the project.

hope that helps,  
krishna

---

<div class="post-metadata">

**Author:** ![bravedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@bravedave](https://www.ruby-forum.com/u/bravedave)\
**Post date:** [March 22, 2007, 5:19pm UTC](https://www.ruby-forum.com/t/how-does-basecamp-scope-distinct-users-in-a-monolithic-dat/89662/3 "2007-03-22T17:19:59Z")

</div>

Take a look at this plugin for clues: [http://agilewebdevelopment.com/](http://agilewebdevelopment.com/)  
plugins/account\_location

–  
Building an e-commerce site with Rails?  
[http://agilewebdevelopment.com/rails-ecommerce](http://agilewebdevelopment.com/rails-ecommerce)

Meet up at RailsConf:  
[http://railsconf2007.conferencemeetup.com/](http://railsconf2007.conferencemeetup.com/)
