"Parts" table creation not working on real environment (no such column: parts.movie_id)


Hi ,

I am trying to test the MovieApp on my computer and I am getting this error:

SQLite3::SQLException: no such column: parts.movie_id: SELECT "actors".* FROM "actors" INNER JOIN "parts" ON "actors"."id" = "parts"."actor_id" WHERE "parts"."movie_id" = ?
Extracted source (around line #15):

  <% @actors.each do |actor|  %>
<div class="actor">
    <%= actor.image %>
    <h3 class="actor-name">  <%= actor.first_name %>  <%= actor.last_name %></h3>

The creation in schema.db file is actually wrong:

create_table "parts", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

although in both models/part.rb

class Part < ActiveRecord::Base
belongs_to :movie
belongs_to :actor

and in db/migrate

class CreateParts < ActiveRecord::Migration
def change
create_table :parts do |t|
t.belongs_to :movie, index: true
t.belongs_to :actor, index: true

I did everything as in the example.

Can anyone help me to understand if there is any other file I need to check? Any idea on what it's going wrong?



Hi Johnthego,

What's the URL you're trying to visit locally?

Also, if you could please create a GitLab or GitHub account and upload your code to it so we can try it out ourselves, that would be great :slightly_smiling:


Hi zystvan,

Thanks for the reply.

I resolved replacing

t.belongs_to :movie, index: true
t.belongs_to :actor, index: true


 t.integer :movie_id, index: true 
  t.integer :actor_id, index: true

I am using Rails locally, so maybe the Association II/Movies II exercise uses a older version?

Thanks again


@johnthego You completely ignored everything in my post. No matter how much I try, I really can't help you if you won't help me.

Please post the link you're trying to visit, and your entire code (through GitLab or GitHub).