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 trial

Ruby

Mary Dickson
Mary Dickson
7,293 Points

"Show" accounts page not working, " Unknown column 'account_entries.account_id' "

edit: This Q is for ActiveRecord basics, "Has & Belongs to Many" (that is super annoying that it didn't link to the video)

I'm stuck around minute 14 after adding the code to make the "show" page work for accounts, getting the message:

Mysql2::Error: Unknown column 'account_entries.account_id' in 'where clause': SELECT account_entries.* FROM account_entries WHERE account_entries.account_id = 1

this is the line it says is a problem: <% @account.account_entries.each do |entry| %>

Any thoughts? I've compared my code to the downloadable project files (was thinking it might just be a plural problem) and I'm not seeing a difference...

2 Answers

Tim Knight
Tim Knight
28,888 Points

Mary, which class is this for? It doesn't seem to say. Since it's MySQL I'm guessing it's Rails right? Have you run your migration to create these table columns?

Mary Dickson
Mary Dickson
7,293 Points

sorry, I updated the post. obviously I intended to link it to the video, don't know why that seems so difficult to do!

Mary Dickson
Mary Dickson
7,293 Points

just checked again and looks like I missed a line in the account entries migration file, so I added that. Thanks! add_column :time_entries, :account_id, :integer

Tim Knight
Tim Knight
28,888 Points

Excellent! I'm glad checking the migration helped.