{"action":"created","issue":{"url":"https://api.github.com/repos/anastasiaalt/quiz/issues/2","repository_url":"https://api.github.com/repos/anastasiaalt/quiz","labels_url":"https://api.github.com/repos/anastasiaalt/quiz/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/anastasiaalt/quiz/issues/2/comments","events_url":"https://api.github.com/repos/anastasiaalt/quiz/issues/2/events","html_url":"https://github.com/anastasiaalt/quiz/issues/2","id":132564426,"number":2,"title":"Yikes... Did I forget to make a Cohort Model/table?","user":{"login":"anastasiaalt","id":14250754,"avatar_url":"https://avatars.githubusercontent.com/u/14250754?v=3","gravatar_id":"","url":"https://api.github.com/users/anastasiaalt","html_url":"https://github.com/anastasiaalt","followers_url":"https://api.github.com/users/anastasiaalt/followers","following_url":"https://api.github.com/users/anastasiaalt/following{/other_user}","gists_url":"https://api.github.com/users/anastasiaalt/gists{/gist_id}","starred_url":"https://api.github.com/users/anastasiaalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anastasiaalt/subscriptions","organizations_url":"https://api.github.com/users/anastasiaalt/orgs","repos_url":"https://api.github.com/users/anastasiaalt/repos","events_url":"https://api.github.com/users/anastasiaalt/events{/privacy}","received_events_url":"https://api.github.com/users/anastasiaalt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"short-matthew-f","id":6674246,"avatar_url":"https://avatars.githubusercontent.com/u/6674246?v=3","gravatar_id":"","url":"https://api.github.com/users/short-matthew-f","html_url":"https://github.com/short-matthew-f","followers_url":"https://api.github.com/users/short-matthew-f/followers","following_url":"https://api.github.com/users/short-matthew-f/following{/other_user}","gists_url":"https://api.github.com/users/short-matthew-f/gists{/gist_id}","starred_url":"https://api.github.com/users/short-matthew-f/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/short-matthew-f/subscriptions","organizations_url":"https://api.github.com/users/short-matthew-f/orgs","repos_url":"https://api.github.com/users/short-matthew-f/repos","events_url":"https://api.github.com/users/short-matthew-f/events{/privacy}","received_events_url":"https://api.github.com/users/short-matthew-f/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2016-02-09T23:11:23Z","updated_at":"2016-02-10T14:50:39Z","closed_at":null,"body":"Hi. Was reviewing all my user stories and read this line again:\r\n\r\nWhen an instructor creates a new cohort through the app, they should be able to enroll students by email address. Each student should receive an email with a link back to the app for them to either sign up or login, unless they've already been registered for a previous class.\r\n\r\nMy first thought was to add an email field for instructor and student (easy). My next thought was that Cohort ought to be it's own Model. However, before I F with my amazing seed file that is totally working and amazing or otherwise mess with my good vibes, thought I'd layout this game plan and get a quick \"yay\" or \"nay\" before I officially kick off the journey of views/controllers/etc.\r\n\r\n\r\nI updated the ERD to show what I think the Cohort/Student/Instructor relationship would be.\r\n\r\nhttps://docs.google.com/presentation/d/1HzwgKg0xh0RhoiE93FZ10NVQLtj4EVdiWVDYCVZr0tw/edit?usp=sharing\r\n\r\nAnd think the Cohort model would look like this\r\n```\r\nclass Cohort < ActiveRecord::Base\r\n  belongs_to :instructor\r\n\r\n  has_many :students\r\nend\r\n```\r\n\r\nand the Student and Instructor models would need to updated as below:\r\n\r\n```\r\nclass Student < ActiveRecord::Base\r\n  has_secure_password\r\n  \r\n  has_many :submissions\r\n  has_many :chosen_options, through: :submissions, source: :option\r\n\r\n  has_one :cohort\r\nend\r\n````\r\n\r\nNot sure exactly if this should be has_one versus belongs_to in this case... The internet isn't super clear either (http://stackoverflow.com/questions/3808926/whats-the-difference-between-belongs-to-and-has-one)\r\n\r\n```\r\nclass Instructor < ActiveRecord::Base\r\n  has_secure_password\r\n\r\n  has_many :quizzes\r\n  has_many :cohorts\r\nend\r\n```\r\n\r\nLastly, the migrations would need to be made and updated as follows:\r\n\r\n1) Create a cohort table / migration like the below\r\n\r\n```\r\nclass CreateCohorts < ActiveRecord::Migration\r\n  def change\r\n    create_table :cohorts do |t|\r\n      t.string :name, :null => false\r\n      \r\n      t.references :instructor\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n2) Update student migration\r\n\r\n```\r\nclass CreateStudents < ActiveRecord::Migration\r\n  def change\r\n    create_table :students do |t|\r\n      t.string :first_name, :null => false\r\n      t.string :last_name, :null => false\r\n\r\n      t.string :username, :null => false\r\n      t.string :password_digest, :null => false\r\n\r\n      t.references :cohort\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/anastasiaalt/quiz/issues/comments/182405030","html_url":"https://github.com/anastasiaalt/quiz/issues/2#issuecomment-182405030","issue_url":"https://api.github.com/repos/anastasiaalt/quiz/issues/2","id":182405030,"user":{"login":"Avizacherman","id":12566734,"avatar_url":"https://avatars.githubusercontent.com/u/12566734?v=3","gravatar_id":"","url":"https://api.github.com/users/Avizacherman","html_url":"https://github.com/Avizacherman","followers_url":"https://api.github.com/users/Avizacherman/followers","following_url":"https://api.github.com/users/Avizacherman/following{/other_user}","gists_url":"https://api.github.com/users/Avizacherman/gists{/gist_id}","starred_url":"https://api.github.com/users/Avizacherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avizacherman/subscriptions","organizations_url":"https://api.github.com/users/Avizacherman/orgs","repos_url":"https://api.github.com/users/Avizacherman/repos","events_url":"https://api.github.com/users/Avizacherman/events{/privacy}","received_events_url":"https://api.github.com/users/Avizacherman/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T14:50:39Z","updated_at":"2016-02-10T14:50:39Z","body":"Anastasia,\r\n\r\nPart of setting up relationships in SQL and ActiveRecord in turn, is that there exists a parent - child relationships between tables. That is, one table OWNs another table. So an instructor table OWNs the cohort table. This means that the instructor should have the cohort, and the cohort belongs to the instructor. Same thing where the cohort table OWNs the students. It just determines which table has the foreign key or reference that points to the other table. In this instance, since the student belongs_to the cohort, the foreign key linking them is on the student. \r\n\r\nDoes this make sense? "}}