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!
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

Wilson Usman
35,206 PointsNameError in Statuses#index 'Creating Friendships'
Showing /Users/Wilson/Projects/treebook/app/views/statuses/index.html.erb where line #11 raised:
undefined local variable or method `gravatar_url' for #<#<Class:0x007fcdebbed668>:0x007fcdebccfd60>
<div class="status">
<div class="row">
<div class="span1">
<%= image_tag status.user gravatar_url %>
</div>
<div class="span7">
<strong><%= status.user.full_name %></strong>
Everything else is to the tee, I've even downloaded the project file to verify it's identical, but I can update this discussion if you think it might be wrong.
After running test/controllers/statuses_controller_test.rb
Finished tests in 0.410229s, 34.1273 tests/s, 80.4429 assertions/s.
1) Error: StatusesControllerTest#test_should_get_index:
ActionView::Template::Error: undefined local variable or method `gravatar_url' for #<# <Class:0x007fe5a22d64e8>:0x007fe5a40f4e98>
app/views/statuses/index.html.erb:11:in `block in _app_views_statuses_index_html_erb__1664802938112526502_70312138456340'
app/views/statuses/index.html.erb:7:in `_app_views_statuses_index_html_erb__1664802938112526502_70312138456340'
app/controllers/statuses_controller.rb:9:in `index'
test/controllers/statuses_controller_test.rb:9:in `block in <class:StatusesControllerTest>'
14 tests, 33 assertions, 0 failures, 1 errors, 0 skips
3 Answers

minzawmra
Courses Plus Student 15,682 PointsIt should be: status.user.gravatar_url

Wilson Usman
35,206 PointsStill getting the same error.
undefined method `gravatar_url' for nil:NilClass

minzawmra
Courses Plus Student 15,682 PointsIt's a different error. Before it didn't recognise the gravatar_url method. Now it's saying the user object is nil. Have you set up the associations in the user class and the status class? Is the database in a consistent state, i.e. the user_id values in the statuses table exist in the users table?