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

Still getting an error after scoping !!

I am still getting this error after scoping the code in my Profiles Controller. This is the Error message:

NoMethodError in ProfilesController#show undefined method `statuses' for #<User:0x007f87c9132650>

This is my Controller Code:

Apps/Controllers/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


Github: https://github.com/Ahmedalthani/Skillbook/commit/0a4a61eb905c328c36d0189d66404a0a39c96d91

1 Answer

The problem is that the User class doesn't have a statuses method. It looks you want to create an association with a Status class. You would need to create a Status model and set the associations.