Can I please get everyone''s opinion? Should customers and admins be on separate tables? I''m developing an application that has two kinds of users, a customer and an administrator. The application basically is a shopping cart. Customers from the internet create their accounts so they are able to buy my products. But there are also administrators (admins). Admins are my employees. They maybe call new customers and try to sell them my products. They have the ability to create, update and manage customers'' accounts. Admins are able to buy products for customers upon their request. I hope that makes sense. Given that admins and customers have different roles but are the same objects, users, should they be in separate tables? Thank you. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5f95a7f7-1368-43f3-ac54-18b0dfa64dfb%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
cooker.kang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2013-May-25 05:27 UTC
Re: Should Customers and Admins be on Separate Tables?
I think you should have two separate tables and two controllers. for administrators, you will have more controllers. Many people will put them in a module and add namespace in routes.rb file to visit them. On Saturday, May 25, 2013 10:55:53 AM UTC+8, Peter wrote:> > Can I please get everyone''s opinion? Should customers and admins be on > separate tables? I''m developing an application that has two kinds of users, > a customer and an administrator. > > The application basically is a shopping cart. Customers from the internet > create their accounts so they are able to buy my products. But there are > also administrators (admins). Admins are my employees. They maybe call new > customers and try to sell them my products. They have the ability to > create, update and manage customers'' accounts. Admins are able to buy > products for customers upon their request. I hope that makes sense. > > Given that admins and customers have different roles but are the same > objects, users, should they be in separate tables? Thank you. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2c869ef6-3246-41bf-9670-12c5eba72f0d%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On 25 May 2013 03:55, Peter <peter-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org> wrote:> Can I please get everyone''s opinion? Should customers and admins be on > separate tables? I''m developing an application that has two kinds of users, > a customer and an administrator.You have given the game away here by describing them as ''kinds of users''. Have one table and distinguish the users types with a boolean, for example. I guess they will both have to login for example, and that is much easier with one table. You could look at the cancan gem to handle the roles but it may be simpler just to use before_filters to control the access.> > The application basically is a shopping cart. Customers from the internet > create their accounts so they are able to buy my products. But there are > also administrators (admins). Admins are my employees. They maybe call new > customers and try to sell them my products. They have the ability to create, > update and manage customers'' accounts. Admins are able to buy products for > customers upon their request. I hope that makes sense. > > Given that admins and customers have different roles but are the same > objects, users, should they be in separate tables? Thank you. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/5f95a7f7-1368-43f3-ac54-18b0dfa64dfb%40googlegroups.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvJgAt_G5oc3zvB9gVVZ3KcvhH_tCAAK89gBWi9iaeztg%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
In agreement with Colin''s point here. If they all log in with the same login form, I''d store them in a single "users" table and have a "roles" field that would help authorize requests using something like "CanCan" . On 25 May 2013 12:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 25 May 2013 03:55, Peter <peter-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org> wrote: > > Can I please get everyone''s opinion? Should customers and admins be on > > separate tables? I''m developing an application that has two kinds of > users, > > a customer and an administrator. > > You have given the game away here by describing them as ''kinds of > users''. Have one table and distinguish the users types with a > boolean, for example. I guess they will both have to login for > example, and that is much easier with one table. You could look at > the cancan gem to handle the roles but it may be simpler just to use > before_filters to control the access. > > > > > The application basically is a shopping cart. Customers from the internet > > create their accounts so they are able to buy my products. But there are > > also administrators (admins). Admins are my employees. They maybe call > new > > customers and try to sell them my products. They have the ability to > create, > > update and manage customers'' accounts. Admins are able to buy products > for > > customers upon their request. I hope that makes sense. > > > > Given that admins and customers have different roles but are the same > > objects, users, should they be in separate tables? Thank you. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/rubyonrails-talk/5f95a7f7-1368-43f3-ac54-18b0dfa64dfb%40googlegroups.com?hl=en-US > . > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvJgAt_G5oc3zvB9gVVZ3KcvhH_tCAAK89gBWi9iaeztg%40mail.gmail.com?hl=en-US > . > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ%3Dox-C2OzpRqXH-nQJRZTkG79wakYmAnaJspp%2BJKenK2sDGYw%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Himanshu Prakash
2013-May-27 05:15 UTC
Re: Should Customers and Admins be on Separate Tables?
Hi, Agree to Colin & Emil. I think this is the good opportunity to implement Single Table Inheritance(STI) pattern in your application. -Himanshu On Sat, May 25, 2013 at 8:32 PM, Emil S <emil.soman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In agreement with Colin''s point here. If they all log in with the same > login form, I''d store them in a single "users" table and have a "roles" > field that would help authorize requests using something like "CanCan" . > > > On 25 May 2013 12:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 25 May 2013 03:55, Peter <peter-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org> wrote: >> > Can I please get everyone''s opinion? Should customers and admins be on >> > separate tables? I''m developing an application that has two kinds of >> users, >> > a customer and an administrator. >> >> You have given the game away here by describing them as ''kinds of >> users''. Have one table and distinguish the users types with a >> boolean, for example. I guess they will both have to login for >> example, and that is much easier with one table. You could look at >> the cancan gem to handle the roles but it may be simpler just to use >> before_filters to control the access. >> >> > >> > The application basically is a shopping cart. Customers from the >> internet >> > create their accounts so they are able to buy my products. But there are >> > also administrators (admins). Admins are my employees. They maybe call >> new >> > customers and try to sell them my products. They have the ability to >> create, >> > update and manage customers'' accounts. Admins are able to buy products >> for >> > customers upon their request. I hope that makes sense. >> > >> > Given that admins and customers have different roles but are the same >> > objects, users, should they be in separate tables? Thank you. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Ruby on Rails: Talk" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/rubyonrails-talk/5f95a7f7-1368-43f3-ac54-18b0dfa64dfb%40googlegroups.com?hl=en-US >> . >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvJgAt_G5oc3zvB9gVVZ3KcvhH_tCAAK89gBWi9iaeztg%40mail.gmail.com?hl=en-US >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CAJ%3Dox-C2OzpRqXH-nQJRZTkG79wakYmAnaJspp%2BJKenK2sDGYw%40mail.gmail.com?hl=en-US. > > > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANQThms2Dvj08LUju2HUCqvEPkbH6uZWXa_%3DHxz%2BjWPD4VuTkA%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On 27 May 2013 06:15, Himanshu Prakash <vision2910-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Agree to Colin & Emil. I think this is the good opportunity to implement > Single Table Inheritance(STI) pattern in your application.Generally I think that the additional complication of using STI for a simple situation such as we have here is not worth the effort. I would just use a single model. Try it both ways and see which you like best. Colin> > -Himanshu > > On Sat, May 25, 2013 at 8:32 PM, Emil S <emil.soman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> In agreement with Colin''s point here. If they all log in with the same >> login form, I''d store them in a single "users" table and have a "roles" >> field that would help authorize requests using something like "CanCan" . >> >> >> On 25 May 2013 12:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>> On 25 May 2013 03:55, Peter <peter-I8Khkwz7QpbQT0dZR+AlfA@public.gmane.org> wrote: >>> > Can I please get everyone''s opinion? Should customers and admins be on >>> > separate tables? I''m developing an application that has two kinds of >>> > users, >>> > a customer and an administrator. >>> >>> You have given the game away here by describing them as ''kinds of >>> users''. Have one table and distinguish the users types with a >>> boolean, for example. I guess they will both have to login for >>> example, and that is much easier with one table. You could look at >>> the cancan gem to handle the roles but it may be simpler just to use >>> before_filters to control the access. >>> >>> > >>> > The application basically is a shopping cart. Customers from the >>> > internet >>> > create their accounts so they are able to buy my products. But there >>> > are >>> > also administrators (admins). Admins are my employees. They maybe call >>> > new >>> > customers and try to sell them my products. They have the ability to >>> > create, >>> > update and manage customers'' accounts. Admins are able to buy products >>> > for >>> > customers upon their request. I hope that makes sense. >>> > >>> > Given that admins and customers have different roles but are the same >>> > objects, users, should they be in separate tables? Thank you. >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups >>> > "Ruby on Rails: Talk" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> > an >>> > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To view this discussion on the web visit >>> > >>> > https://groups.google.com/d/msgid/rubyonrails-talk/5f95a7f7-1368-43f3-ac54-18b0dfa64dfb%40googlegroups.com?hl=en-US. >>> > For more options, visit https://groups.google.com/groups/opt_out. >>> > >>> > >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Talk" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvJgAt_G5oc3zvB9gVVZ3KcvhH_tCAAK89gBWi9iaeztg%40mail.gmail.com?hl=en-US. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/CAJ%3Dox-C2OzpRqXH-nQJRZTkG79wakYmAnaJspp%2BJKenK2sDGYw%40mail.gmail.com?hl=en-US. >> >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CANQThms2Dvj08LUju2HUCqvEPkbH6uZWXa_%3DHxz%2BjWPD4VuTkA%40mail.gmail.com?hl=en-US. > > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvrg66QhHa%2Bn3Nyh29HuSQSOkax0L9iQJyJt0Bq6_8Ltw%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On Friday, May 24, 2013 10:55:53 PM UTC-4, Peter wrote:> > Can I please get everyone''s opinion? Should customers and admins be on > separate tables? I''m developing an application that has two kinds of users, > a customer and an administrator. > > The application basically is a shopping cart. Customers from the internet > create their accounts so they are able to buy my products. But there are > also administrators (admins). Admins are my employees. They maybe call new > customers and try to sell them my products. They have the ability to > create, update and manage customers'' accounts. Admins are able to buy > products for customers upon their request. I hope that makes sense. > > Given that admins and customers have different roles but are the same > objects, users, should they be in separate tables? Thank you. > >I also prefer adding a boolean to the user table, but I can tell you I''ve seen a lot of cases where separate tables and controllers are created. I use devise for authentication and the documentation clearly recommends separate tables and controllers. I''ve never understood why, I just assumed their needs were more involved than mine, I''ve always just added the boolean and it''s been pretty straightforward. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fc3d08c6-f5bd-44e0-b97a-d41e1aa71378%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.