# Shared user model design... many possibilities

**URL:** <https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905>\
**Category:** Rails\
**Created:** [February 22, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905 "2008-02-22T16:35:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maigre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@maigre](https://www.ruby-forum.com/u/maigre)\
**Post date:** [February 22, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905/1 "2008-02-22T16:35:37Z")

</div>

Hi

Got many web applications I wish to bind into a network for a better  
user experience. The “User” model would then be shared so that any  
registered user may enjoy all websites without setting the same profile  
and password.

Here are the design options:

- One rails app serving the user model to other websites using active  
resource: I don’t like very much this option since I’m afraid it would  
be too slow…
- Running an LDAP server. Typical rails attributes (created\_at,  
updated\_at) and typecasting may be an issue or am I wrong ?
- OpenID: I like this technology and its principles but I’m afraid  
migrating tens of thousands accounts from different websites and without  
altering their passwords would be a pain in the… for the development  
team as for the user who maybe won’t apreciate this new authentication  
process with back and forth redirection between the openid server and  
the web application…

What do you think ? Any other suggestion ?

---

<div class="post-metadata">

**Author:** ![maigre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@maigre](https://www.ruby-forum.com/u/maigre)\
**Post date:** [February 22, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905/2 "2008-02-22T17:05:19Z")

</div>

On 22 Feb 2008, at 15:35, Marcel Mm wrote:

> - One rails app serving the user model to other websites using active  
> resource: I don’t like very much this option since I’m afraid it would  
> be too slow…

What we’ve done is have one rails app serving the user models, however  
the client rails apps then cache the data locally, so no speed concerns.  
Updates are relatively infrequent so we can be very stupid about  
invalidating the cache.

Fred

---

<div class="post-metadata">

**Author:** ![maigre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@maigre](https://www.ruby-forum.com/u/maigre)\
**Post date:** [March 11, 2008, 10:12pm UTC](https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905/3 "2008-03-11T22:12:35Z")

</div>

Can you provide more details on how you created a rails app that  
serves the user model to other apps? I’m investigating this option  
right now and I can’t find anything about the pros/cons or even how to  
implement it. I know Active Resource is the key but how do you cache  
all the session data in the local app? Any help or direction would be  
appreciated. I don’t want to go too far down this path if it isn’t  
going to work out. 🙂

Nate

On Feb 22, 12:01 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![maigre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@maigre](https://www.ruby-forum.com/u/maigre)\
**Post date:** [March 11, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/shared-user-model-design-many-possibilities/129905/4 "2008-03-11T22:42:43Z")

</div>

On 11 Mar 2008, at 21:11, Etandrib wrote:

> Can you provide more details on how you created a rails app that  
> serves the user model to other apps? I’m investigating this option  
> right now and I can’t find anything about the pros/cons or even how to  
> implement it. I know Active Resource is the key but how do you cache  
> all the session data in the local app? Any help or direction would be  
> appreciated. I don’t want to go too far down this path if it isn’t  
> going to work out. 🙂

We’ve got a table that stores what we’ve got from the remote app.  
Another row in another table states whether the cache is valid, when  
someone edits information in the app that owns the user data it pings  
all the other apps to tell them they should dump their cache (this  
just flips a flag in the cache status table). Next time the app needs  
to get some data it checks whether the cache is valid and if not  
copies the data over again.

I suppose a key thing is the frequency of updates. It’s not that  
frequent for us, so we can be very clumsy with our cache: changing one  
user triggers a refresh of the info for all users. This may or may not  
work for you.

We started out with activeresource (or rather a bastardisation of it  
on the client side since we were running rails 1.2 at the time), but  
it turned out that for the amount of data we were moving it was a bit  
slow (i can’t quite remember the timings, perhaps 2-3 seconds) and the  
slow bit was parsing the xml. We now just dump attribues with  
Marshal.dump and send that down the wire.

Fred
