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


Tim Smith
Tim Smith
11,164 Points

uninitialized constant UserFriendshipsController

Hi Everyone,

I am working on adding social features to treebook. I am on the "Creating the Friendship Form" video, about 3/4 the way through. We just added:

<%= link_to "Add Friend", new_user_friendship_path(friend_id: @user), class: 'btn' %>

to show.html.erb.

In the browser, when I click that new link, I do not get the expected page. I get a Routing error:

uninitialized constant UserFriendshipsController

I have deduced from the error that the bug is most likely in the "config/routes.rb or "user_friendship_controller.rb, but I can't seem to find it.

Please help

1 Answer

Jason Seifer
Jason Seifer
Treehouse Guest Teacher

Hey Tim Smith does your user_friendship_controller.rb have an "s" in it? If not, that may be the issue and Rails is looking for a pluralized version of it. The solution in that case would be to rename it to user_friendship*s*_controller.rb and change the class name to UserFriendshipsController in the file itself.