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

full_name Not Showing on Profile Page

every thing is working bt user name is not showing in my profile page.

This is my show.html.erb file.

        <div class="page-header">

    <h1> <%= @user.full_name %> </h1>

        </div> 

         <% if @statuses %>

         <% @statuses.each do |status| %>

            <div class="well">

            <%= status.context %>

          <hr/>

    <%= link_to time_ago_in_words(status.created_at), status_path(status) %> ago

          </div>

           <% end %>

           <% end %>

Greatly appreciate any help. Thank you!

1 Answer

Try using the "yield" function before @user.full_name .. I'm stabbing in the dark here, but it worked with a project I'm working on in a similar manner.

No, this code is not helping me :(

      <%= yield @user.full_name %>

It's likely that you haven't fully defined what @user.full_name is yet. Can you post all of the code for Me and I'll try to help you the best I can

when i try the code without @ symbol it's give me error

undefined local variable or method `user' for #<#<Class:0x51d1b20>:0x51d06c8>

Go ahead and post all of your code and I'm sure I can figure out what's going on.

My profile_controller_test.rb look like this

require 'test_helper'

class ProfilesControllerTest < ActionController::TestCase

test "should get show" do

get :show, id: users(:sarah).profile_name

assert_response :success

assert_template  'profiles/show'

  end

test "should render a 404 on profile not found" do

get :show, id: "doesn't exist"

assert_response :not_found

end

  test "that variables are assigned on successful profile viewing" do

 get :show, id: users(:sarah).profile_name

    assert assigns(:user)

    assert_not_empty assigns(:statuses)

        end

  test "only shows the correct user's statuses" do

  get :show, id: users(:sarah).profile_name

 assigns(:statuses).each do |status|

  assert_equal users(:sarah), status.user

   end

  end

  end

Are you using Rspec or MiniTest suite?

No...... I' m following the video of teamtreehouse.