1

Building off this question, How to implement an achievement system in RoR would I have a user_id column in my Achievement table?

Community
  • 1
  • 1
jktress
  • 1,097
  • 7
  • 11
  • really a down vote? Sorry, I thought this was a site for asking questions about programming. My bad. – jktress Sep 19 '11 at 03:56
  • I'd like to better understand the reasoning behind closing this question. I'm pretty sure 'would I have a user_id column in my Achievement table' is a "real" question. – jktress Oct 11 '11 at 15:33

1 Answers1

0

Assuming you are using the accepted answer way of doing this, then yes, you would have a user_id in your achievements table. You can tell this because in the Achievements model, it has:

belongs_to :user

If you were generating the achievements model through a rails generator, it would look like this:

rails g model Achievement user:references ........

Where ..... is the other fields in the achievement model.

Joel Friedlaender
  • 2,191
  • 1
  • 18
  • 24
  • Thanks Joel, I started over thinking this because I read on the linked question about a UNIQUE index on the 'Type' column. That made me wonder how multiple users could have the same achievements. Wouldn't the type be non-unique in that case? – jktress Sep 19 '11 at 16:22
  • They propose an index on the Type and User_ID column (the index across both, not two indexes). The combination of Type and User_ID being unique prevents multiple of the same achievement being recorded to one user. – Joel Friedlaender Sep 20 '11 at 12:23