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 Build a Simple Ruby on Rails Application Building the Profile Page Scoping

Building the Profile Page, Change the Status

I'm having a lot of trouble, and I've watched the video 5 times and feel like I'm doing what's modeled, but it isn't working. I must be missing something. "Change the Status find to be scoped to the user." Here's my code:

class ProfilesController < ApplicationController
  def index
    @user = User.find_by_profile_name(params[:id])
    @statuses = @user.Statuses.all
  end
end

3 Answers

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

try @statuses = @user.statuses.all

you wrote Statuses.all with the capital letter

That worked! I had tried using all lowercase before and couldn't get it to work, but now it does! Thank you, Roberto!

i am getting the same error. This is the error that i am getting:

undefined method `statuses' for #<User:0x007fa2a6527df8>

My code looks like this

//profiles_controller.rb

class ProfilesController < ApplicationController

def show @user = User.find_by_profile_name(params[:id]) if @user @statuses = @user.statuses.all render action: :show else render file: 'public/404', status: 404, formats: [:html] end end

end