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 trialkbajorin
1,883 PointsDELETE
DELETE
5 Answers
Tim Timmsen
685 Pointshey,
that's because you have old entries (statuses) that hadn't had a "first_name" or "last_name" value assigned when they were created, hence the value returned when asked for is "nil".
Simply remove the line <%= status.user.full_name%> from your viewfile, delete old statuses, and add it back in.
hope tha helps.
Jason Seifer
Treehouse Guest TeacherIf you're still having trouble, try following along with Jim in this video: http://teamtreehouse.com/library/programming-2/build-a-simple-version-of-facebook/customizing-forms/getting-the-latest-changes
Sean Everett
1,681 PointsSo I had this problem and struggled for hours trying to figure it out. My solution was to add Delete to the edit.html.erb page:
<%= link_to "Delete", @status, method: :delete, data: { confirm: "Are you sure your want to delete this status?"} %>
(don't forget the '@' symbol in front of status on this page, it is not the index.html.erb page)
Then make sure you've removed this line from both the show and index pages:
<%= status.user.full_name%>
Then change the route in the browser by hand:
http://localhost:3000/statuses/13/edit
in your case, you may need to change 13 to be [1, 2, ..., 13, ..., 15, ...] for however many statuses you've ever created.
You then delete each one.
Then go back in and create a new status. If you have the rest of the code up to date the dropdown box for user should show your "first name last name" (in my case, Sean Everett).
Note: this assumes that in your _form.html.erb file that you have this line:
<%= f.input :user_id, collection: User.all, label_method: :full_name %>
Create your new status, then add back this line to both show and index files: <%= status.user.full_name%>
Then refresh and you should no longer be getting an error.
The way I got to this was by visiting the actual github page for this step in the process and physically copying and pasting every file's code to make sure I hadn't mistyped (sometimes sublime text picks up weird blank spaces that may be causing issues with your code).
Hope this helps.
Joona Tuunanen
5,297 PointsThanks a lot Sean. I had the same problem and your solution helped a lot.
Sean Everett
1,681 Points@Joona, not a problem man. This stuff can get extremely complex extremely quickly so I figured since Jason and Jim did such a great job of simplifying things, that I could help a little on my weird edge case.