Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJorge Garcia
6,496 Pointsrake aborted! StandardError:
This is what I get when i try to "bin/rake db:migrate". Any help would be greatly appreciated.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
[DEPRECATION] last_comment
is deprecated. Please use last_description
instead.
== CreateTodoItems: migrating ================================================
-- create_table(:todo_items)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined method reference' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0xbadb3674>
/home/treehouse/projects/odot/db/migrate/20160508194053_create_todo_items.rb:4:in
block in change'
/home/treehouse/projects/odot/db/migrate/20160508194053_create_todo_items.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Here is line 1-10 of the file 20160508194053_create_todo_items.rb
class CreateTodoItems < ActiveRecord::Migration
def change
create_table :todo_items do |t|
t.reference :todo_list, index: true
t.string :content
t.timestamps
end
end
end
2 Answers
Seth Kroger
56,413 PointsThe error is happening because you used t.reference instead of t.references plural. It also looks like you're missing some things from the migration file. This is what I have in my saved project.
class CreateTodoItems < ActiveRecord::Migration
def change
create_table :todo_items do |t|
t.references :todo_list, index: true, foreign_key: true
t.string :content
t.timestamps null: false
end
end
end
Jorge Garcia
6,496 PointsThant did it. Thank you Seth!