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 trialJennifer Crawshaw
17,878 PointsSchema not matching with Time Entry model
I am unable to add time entries to a customer. When I compared my TimeEntry model to the schema, they do not match up, even after running 'rake db:migrate'
class CreateTimeEntries < ActiveRecord::Migration
def change
create_table :time_entries do |t|
t.float :time
t.belongs_to :customer
t.belongs_to :employee
t.timestamps
end
end
end
create_table "time_entries", force: true do |t|
t.datetime "created_at"
t.datetime "updated_at"
end
Any help is appreciated!
3 Answers
Jim Withington
12,025 PointsThis happened to me, too! The reason was that I forgot to save my file before my rake db:update
. I fixed it by:
- `
rake db:rollback
two times - "editing" all of the files (basically, I added a space, deleted that space, and then saved the file)
- running
rake db:migrate
again.
So basically, I rolled it back, made sure to edit/save the files, and then said "hey run this again!"
Hope this helps!
Jennifer Crawshaw
17,878 PointsI was working through the lesson on Active Record Basics. My schema is the code on the bottom screen of my original post.
Maciej Czuchnowski
36,441 PointsDo you have any other migrations in the db/migrate folder? I could look at your whole code and see how the app behaves if you could publish it on GitHub.
Kyle Daugherty
16,441 PointsBy chance, did you edit your migration file after you already ran rake db:migrate? If so, you need to rollback your changes or just create a new migration to add the additional columns you're needing.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsPlease give us more details. What steps did you take to create all your models and migrations? How does your schema look like and what doesn't match exactly? Can you link videos that instructed you what to do?