# How do you store values for each specific user?

**URL:** <https://www.ruby-forum.com/t/how-do-you-store-values-for-each-specific-user/142519>\
**Category:** Rails\
**Created:** [July 8, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/how-do-you-store-values-for-each-specific-user/142519 "2008-07-08T20:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WalkerW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/67e7ee/32.png) [@WalkerW](https://www.ruby-forum.com/u/WalkerW)\
**Post date:** [July 8, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/how-do-you-store-values-for-each-specific-user/142519/1 "2008-07-08T20:16:10Z")

</div>

Just learning Rails trying to get a handle on something in a very  
basic sense:

I can create a login tool, I can create a funciton that creates a  
table based on skills but I have no idea how to make skills local to  
each user? I was every used to have a list of skills that when they  
login are displayed… Each user can’t have his own database table can  
he? What is the general way of handling this.

Walker

---

<div class="post-metadata">

**Author:** ![WalkerW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/67e7ee/32.png) [@WalkerW](https://www.ruby-forum.com/u/WalkerW)\
**Post date:** [July 8, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/how-do-you-store-values-for-each-specific-user/142519/2 "2008-07-08T20:18:01Z")

</div>

On Jul 8, 6:37 pm, WalkerW [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Just learning Rails trying to get a handle on something in a very  
> basic sense:
> 
> I can create a login tool, I can create a funciton that creates a  
> table based on skills but I have no idea how to make skills local to  
> each user? I was every used to have a list of skills that when they  
> login are displayed… Each user can’t have his own database table can  
> he? What is the general way of handling this.

My answer is going to be a bit vague, since your question is a bit  
vague. If you skills table has a user\_id column then a user’s skills  
are simply those with the appropriate user\_id. Rails’ associations  
will do most of this for you

class Skill  
belongs\_to :user  
end

class User  
has\_many :skills  
end

some\_user.skills =\> The skills for that user

Fred

---

<div class="post-metadata">

**Author:** ![WalkerW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/67e7ee/32.png) [@WalkerW](https://www.ruby-forum.com/u/WalkerW)\
**Post date:** [July 8, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/how-do-you-store-values-for-each-specific-user/142519/3 "2008-07-08T21:51:23Z")

</div>

You can also map the skill resources as being nested under users in  
your routes.rb.

map.resources :users, :has\_many =\> :skills

This would provide you a way to access a user’s skills with the  
following URI:

[http://localhost:3000/users/1/skills](http://localhost:3000/users/1/skills) # The array of skills for a  
user with id == 1

And you can build the URI with something like:

user\_skills\_url(user\_id) ==\> [http://localhost:3000/users/1/skills](http://localhost:3000/users/1/skills)

Note: assume user\_id = 1

On Jul 8, 2:17 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
