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

Individual statuses not appearing on profile page

Hi, i've finally gotten the individual profile pages to appear on my Ruby on Rails application. However, I can't see individual statuses on the page. I get a shaded-in box and a link that says "X minutes ago" that reaches the actual status, and the feed itself also shows the status.

show.html.erb:

<div class ="page-header">
    <h1><%= @user.full_name %></h1>
</div>

<% if @user.statuses.any? %>
  <% @user.statuses.each do |status| %>
    <div class="well">
      <% status.content %>
      <hr />
      <%= link_to time_ago_in_words(status.created_at), status_path(status) %> ago
    </div>
  <% end %>
<% end %>

profiles_controller.rb:

class ProfilesController < ApplicationController
  before_action :set_user, only: [:show]

  def show
    if @user
      @statuses = Status.all
      render action: :show
    else
      render file: "public/404", status: 404, formats: [:html]
    end
  end

  private

   def set_user
    @user = User.where(profile_name: params[:profile_name]).first
   end
end

My github repo: https://github.com/yamilethmedina/wheels_registration.git

And a profile page running on the rails server: https://wheels-registration-yamilethmedina.c9.io/caguilera

Thanks for your help!

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

This:

<% status.content %>

should be

<%= status.content %>

You need the = sign to actually display the evaluated content of the erb tag.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Also, you may want to change this:

@statuses = Status.all

in your show action to this

@statuses = @user.statuses.all

And then just do @statuses.each in the view.

Such a dumb typo...this worked, thanks! :)