On 13 July 2016 at 16:14, Johnny Stewart <[email protected]> wrote: > Colin Law wrote in post #1184575: >> On 11 July 2016 at 19:41, Johnny Stewart <[email protected]> wrote: >>> in a table like ChefInfo >>> >>> then if user1 is a chef, he would have all the user info + type Chef and >>> he would have an entry in the chef table >>> >>> user2 if she was a footballer would have all the user info + type >>> Athlete and she would have an entry in the athlete table >>> >>> So, you don't need to keep all the chef or athlete data in the user >>> table - you just have a reference to that info in the relevant table.. >> >> That does not sound like STI, STI is where you *do* store all the >> information in one table (Single Table Inheritance), but ignore the >> irrelevant parts dependent on the type. >> >> Colin > > As I understand it STI is best suited to situations where the data is > the same but the behaviour is different. For the User model it really > only has to handle registrations etc. I don't think there is any need to > hold data pertaining to that user being a chef. > > All it needs is maybe profile name, email address, password etc. That > needn't change here. > > Using STI we store that one extra column of type - then use that to > see what table that user's extra info is held in (chef_info, > athlete_info etc).
I do not believe that is the usual use case for STI. See [0] for a good description of the use of STI. Colin [0] http://eewang.github.io/blog/2013/03/12/how-and-when-to-use-single-table-inheritance-in-rails/ Colin -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLu2EkHsx1RLZO3DZM-uSf_x%2BA-gETqoq46pe--Nev6gEA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

