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

guilliatt
guilliatt
10,743 Points

Scoping Code Challenge

Any ideas why this fails the code challenge? I believe my answer is identical to the successful code in the instruction video?!

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

4 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

OK, what I said earlier + you also have to remove that whole IF statement.

class ProfilesController < ApplicationController
  def index
    @user = User.find_by_profile_name(params[:profile_name])
    @statuses = @user.statuses.all
  end
end
Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

You used capital case in Statuses, which suggests the name of the model. But you want a virtual attribute called statuses, all lower case.

David Ker
David Ker
14,439 Points

Looks like you might need an additional end after you assign @statuses.

guilliatt
guilliatt
10,743 Points

@Maciej, thanks for your input, but sadly it doesn't work either with upper case or lower case, nor does the singular or plural of status/statuses make a difference!

@David, thanks likewise, but again I've found this makes no difference to the successful completion of the task!