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

Deleted user's profile from my treebook and now nothing works

Hi, I am going through Build a simple RoR application videos. However, I am currently going over the "Creating a profile page" videos and I was not sure about the profile name of the user I had registered, therefore I deleted it so that I can create a new one and continue with my videos. After I deleted the user I got :

NoMethodError in Statuses#index

Showing /var/lib/stickshift/5166c81be0b8cdcfca00007a/app-root/data/469951/app/views/statuses/index.html.erb where line #9 raised:

undefined method `full_name' for nil:NilClass Extracted source (around line #9):

6: 7: <% @statuses.each do |status| %> 8: <div class="status"> 9: <strong><%= status.user.full_name %></strong> 10: <p><%= status.content %></p> 11: <div class="meta"> 12: <%= link_to time_ago_in_words(status.created_at) + " ago", status %> Rails.root: /var/lib/stickshift/5166c81be0b8cdcfca00007a/app-root/data/469951

Application Trace | Framework Trace | Full Trace app/views/statuses/index.html.erb:9:in block in _app_views_statuses_index_html_erb__565064848992858053_36962300' app/views/statuses/index.html.erb:7:ineach' app/views/statuses/index.html.erb:7:in _app_views_statuses_index_html_erb__565064848992858053_36962300' app/controllers/statuses_controller.rb:9:inindex' Request

Parameters:

None Show session dump

Show env dump

Response

Headers:

None

this error and I cannot start the server again, nor can I do anything. Can you please tell me how to fix it and continue with my videos. Thanks in advance.

P.S. I believe I should delete the statuses from the db since they have all been created by a user who was deleted. However, I am not sure I should and I do not know how to do this.

Regards

1 Answer

Fixed it: > rails console > Status.delete_all