Note that there are some explanatory texts on larger screens.

plurals
  1. POProper structure for a join table in Rails 3.2
    primarykey
    data
    text
    <p>I am rewriting a PHP based support ticket system in Rails and have run into a snag. I have my users table created and my tickets table created</p> <pre><code>create_table "tickets", :force =&gt; true do |t| t.integer "user_id", :null =&gt; false t.integer "department_id", :null =&gt; false t.integer "upload_id", :null =&gt; false t.string "subject", :null =&gt; false t.text "body", :null =&gt; false t.string "status_id", :null =&gt; false t.text "url", :null =&gt; false t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false end create_table "users", :force =&gt; true do |t| t.string "fName", :null =&gt; false t.string "lName", :null =&gt; false t.string "seKey", :null =&gt; false t.boolean "isAdmin" t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false t.string "auth_token" end </code></pre> <p>Everything is working great, I am able to create tickets, etc... Now I am needing to assign 1 or more admins to a ticket and am not sure if I should use a has_and_belongs_to_many relationship or a has_many :through relationship.</p> <p>The way it is currently setup in PHP is just using a join table that matches a userID with a ticketID. I don't think I will ever need any other data relating to the relationship other than that so is has_and_belongs_to_many the best option?</p> <p>Also, will this cause an issue since the ticket is already associated with a record in the user table (the original creator)? Basically a ticket will have multiple connections to the users table, one will be the person who submitted it and the rest are users who are assigned to handle it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload