Note that there are some explanatory texts on larger screens.

plurals
  1. PORails: 'Could not find table' in a many-to-many relationship
    primarykey
    data
    text
    <p>I have two tables set up in a many-to-many relationship: Incidents and Users. When a user is logged in, and they view the /incidents page (the index), I want to display all the incidents they are associated with. Unfortunately, the following error occurs:</p> <pre><code>Could not find table 'incidents_users' </code></pre> <p>It seems rails is looking for the table 'incidents_users', when I actually created the table 'users_incidents'. 'users_incidents' simply holds the user_id and incident_id.</p> <p>Am I missing something obvious? I'm relatively new to rails, so the problem could be something simple that I've overlooked.</p> <p>Here is the relevant section of the incidents_controller.rb</p> <pre><code># GET /incidents # GET /incidents.xml def index @incidents = current_user.incidents respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @incidents } end end </code></pre> <p>Here is the relevant section of the index.html.erb</p> <pre><code>&lt;% for incident in @incidents %&gt; &lt;tr&gt; &lt;td&gt;&lt;%=h incident.other_id %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=h incident.title %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Show', [@customer, incident] %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Edit', edit_customer_incident_path(@customer, incident) %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Destroy', [@customer, incident], :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; </code></pre> <p>Thanks! Please let me know if more information would be helpful.</p>
    singulars
    1. This table or related slice is empty.
    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