book_id not found wheen db:seed is used


#1

When I try to use "rake db:seed" I get the error: "unknown attribute: book_id"

This is my code:
review.rb

class Review < ActiveRecord::Base
belongs_to :book
end

book.rb

class Book < ActiveRecord::Base
has_many :review
end

migration file

class CreateReviews < ActiveRecord::Migration
def change
create_table :reviews do |t|
t.string :author
t.string :comment
t.references :book
t.timestamps
end
end
end

Any idea?


#2

If you look at the db:schema.rb

create_table "reviews", force: true do |t|
t.string "author"
t.string "comment"
t.integer "Book_id"
t.datetime "created_at"
t.datetime "updated_at"
end

The book_id is capitalized. I'm not sure why this is but I changed the seed file they gave to capitalize the instances of "book_id" and it seemed to work.
https://s3.amazonaws.com/codecademy-content/projects/3/bookmarks/seeds.rb.html


#3

Did you by chance capitalize "Book"

t.references :book

in the reviews migration file? Or did you manually create the book_id column?


#4

@scriptblaster84494: i tried everything book, Book, books, Books. nothing worked.
@jobrien1956: it seems they have changed the course. the training is not longer listed. so i am not able to try your solution.