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 ActiveRecord Basics AR Extensions Model Versioning

undefined method `cost'

So accidentally deleted what i believe was my models folder and went to DL the project files and through all the headache of trying to get things up and running again with the project files i was able to get pretty far until this error.

NoMethodError in Accounts#show undefined method `cost' for #<TimeEntry:0x00000005b24788>

This happens when i click on an account that has a time entry

it narrows it down to line 4 in /app/views/accounts/show.html.erb

which is

Total Cost: $#<%= (@account.account_entries.map &:cost).sum %>

if i remove that line it works fine and i can see that account. I dont even remember adding that line. Looks like :cost isnt defined? how do i fix this and where did that come from? helpppppp! thanks!

Found it! In the using callbacks video we changed cost to self.per_hour and added calculate_amount! so you simply change "..entries.map &:cost)" to "..entries.map &:calculate_amount!)"