Robert Walker | 8 Jul 21:39

Re: How do you store values for each specific user?


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    # 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

Note: assume user_id = 1

On Jul 8, 2:17 pm, Frederick Cheung <frederick.che...@...>
wrote:
> On Jul 8, 6:37 pm, WalkerW <liberata...@...> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane