Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Simple Ruby on Rails Application Building the Profile Page Testing the Profiles Controller

Profiles page doesn't load

When I try to load a profile page, I get this error.

NameError in Profiles#show Showing /home/ubuntu/workspace/app/views/profiles/show.html.erb ( where line #6 ( <% statuses.each do |status| %>) raised:

undefined local variable or method `statuses' for #<#<Class:0x00000005712578>:0x00000005b7b150> (my markdown isn't showing up correctly, the first line is

<% if @statuses %>
   <% if @statuses %>
      <% statuses.each do |status| %>
             <div class="well">
              <% status.content %>
              <hr />

I'm using Rails 4. What should I do?

3 Answers

It will be undefined because it's looking for a local variable instead of a instance variable. Simply name it to @statuses, and it should work!

Yamileth Medina has this solved your problem?

I've tidied up your origin comment - markdown was looking good, just needed a couple of line breaks :-)

Tom Cawthorn this solved the particular issue of the pages not showing up at all, but now I end up seeing the profile page for the exact same user, no matter which person's profile page I attempt to visit. (For instance, if I go to "/britneyspears", I still see Nancy Drew's statuses instead of Britney Spears'. Do you have any ideas of how to fix it?

Thanks!

Hmm.. Have you left some test code somewhere so you're always pulling out the same user? Also check your database to see if all the users have the same url-slug of /britneyspears

Tom Cawthorn Where in the database should I check for the URL slug and test code? I'll go looking for it, but if you could help point me in the right direction that would be great!