Just started learning about Rails and I''m trying to figure modeling out in my head and I was hoping for some direction. Maybe I am thinking too much and have confused myself but I figure if I don''t get it right now it may get worse in the future. This is my first attempt to create a site: So I am trying to model users. There are multiple users with different access rights. So what is not right in my head is this: -Do I create one User model and then within the table distingush the different users in a field? or -Do I create a model for each of the users? (Like: Admin model, Agent model, Tutor model, Parent model, Student Model ...) In my model I have agents, tutors, parents, students, and admin. Tutors provide services that can be purchased through the site by students or parents. The Tutors are signed up to an account by agents. Which would be right from the following? Agents have many tutors or should I say Agents have many accounts (and then tie the tutor to the account? which I guess would then be accounts have one tutor?) I''m wondering if I just answered my first question about what should be a model or not. If an object has associations then is it automatically a model? One of the things that is making me think that there should only be the one User model is that if I have a login system and each user group sees something different then how does the login controller check against multiple different user groups in different models? Thanks for any help in advance. MC --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 19, 11:13 am, MC <amev...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Just started learning about Rails and I''m trying to figure modeling > out in my head and I was hoping for some direction. Maybe I am > thinking too much and have confused myself but I figure if I don''t get > it right now it may get worse in the future. This is my first attempt > to create a site: > > So I am trying to model users. There are multiple users with different > access rights. So what is not right in my head is this: > > -Do I create one User model and then within the table distingush the > different users in a field? > > or > > -Do I create a model for each of the users? (Like: Admin model, Agent > model, Tutor model, Parent model, Student Model ...) > > In my model I have agents, tutors, parents, students, and admin. > Tutors provide services that can be purchased through the site by > students or parents. The Tutors are signed up to an account by agents. > > Which would be right from the following? > Agents have many tutors > or should I say > Agents have many accounts (and then tie the tutor to the account? > which I guess would then be accounts have one tutor?) > > I''m wondering if I just answered my first question about what should > be a model or not. If an object has associations then is it > automatically a model? > > One of the things that is making me think that there should only be > the one User model is that if I have a login system and each user > group sees something different then how does the login controller > check against multiple different user groups in different models? > > Thanks for any help in advance. > > MCHow about having a User and Role model and having them associated with each other via a HABTM or a has_many :through? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why not use Single Table Inheritance where you have a column ''type'' for storing the type of user. Then you will be having a single User model. I think this might be helpful to you: http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Also in the Book Practical RAils Social Networking Sites the author Alan Bradburne works through this by using a role model and assigning roles to the users. The Administrator then controls who has what role. You might look at this method I am a newb also - so books and forems help alot - Owen On Sep 19, 5:53 am, ruby rails <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Why not use Single Table Inheritance where you have a column ''type'' for > storing the type of user. Then you will be having a single User model. > > I think this might be helpful to you:http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---