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

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,440 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,440 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! :)