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.


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.