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
Mitch Malone
3,577 PointsLinking to profile
In the Building a Profile Page stage, we print all the statuses from each user. But there's no way to get to these profiles besides putting the name in the URL.
I've tried to do this but I keep getting this error:
No route matches {:controller=>"profiles", :action=>"show"}
Here is my routes:
get '/:id', to: 'profiles#show', as: :profile
Here is my Profiles Controller (same as in the tutorial):
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
And here's my applications layout view:
<li><%= link_to current_user.full_name, profile_path %></li>
The profile pages render but nothing else does.
What am I doing wrong?
2 Answers
Jason Seifer
Treehouse Guest TeacherHey Mitch Malone
Try changing this:
<li><%= link_to current_user.full_name, profile_path %></li>
To this:
<li><%= link_to current_user.full_name, profile_path(current_user.profile_name) %></li>
And let me know if that works.
Mitch Malone
3,577 PointsGot it. Thanks Jason Seifer !