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 trialNicholas Campanini
8,626 PointsNoMethodError: undefined method 'time_entries' -- when trying Customer.first.time_entries in Rails console.
Trying to follow along with exactly is being done in this screencast since I'm pretty new to Rails and development in general.
The stack trace is quite long, so I wouldn't know exactly what to include here to help debug the issue.
Any help is appreciated!
Nicholas Campanini
8,626 PointsOK, I will copy/paste the stack trace when I have a good free moment (and can recreate it). I didn't want to leave anyone hanging without some kind of update.
Sorry, and thanks.
Maciej Czuchnowski
36,441 PointsNo problem, take your time :)
2 Answers
Aaron Kaye
10,948 PointsThis is a wild shot but this is what happened to me, I made a typo in my create_time_entries migration back in the previous video where I said this:
t.belongs_to :customer_id instead of t.belongs_to :customer
I noticed the when I looked in the schema file because it said customer_id_id. I was getting the same error you were getting. So just double check your schema and migrations and if you need to change a column:
def create rename_column :table_name, :old_column, :new_column end
Jim Withington
12,025 PointsYou might want to check your schema. I'm on this lesson right now, and the schema for time_entires should look like this:
create_table "time_entries", force: true do |t|
t.float "time", limit: 24
t.integer "customer_id"
t.integer "employee_id"
t.datetime "created_at"
t.datetime "updated_at"
If something about your schema looks weird, it might be the same sort of error that I outlined here.
Hope this helps!
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsYou can copy and paste all of it and use markdown to make it more readable, something might be there ;)