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


#1

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):

<h2>Cast</h2>
  <% @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
end

although in both models/part.rb

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

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
t.timestamps
end
end
end

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?

thanks!


#2

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:
Thanks!


#3

Hi zystvan,

Thanks for the reply.

I resolved replacing

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

with

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

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

Thanks again


#4

@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).