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
Robert Borsey
Courses Plus Student 9,636 Pointshaving profile page problem(can someone help please)
Well this is the problem when I try and run localhost:3000/robertborsey I get this message The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. This is coming out of my public 404.html file
I believe that my if statement is not executing so its executing my else statement.
This is my profiles_controller.rb file
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
This is my routes.rb file
Treebook::Application.routes.draw do
get "profiles/show"
devise_for :views
devise_for :users
devise_scope :user do
get 'register' , to: 'devise/registrations#new' , as: :register
get 'login' , to: 'devise/sessions#new' , as: :login
get 'logout' , to: 'devise/sessions#destroy' , as: :logout
end
resources :statuses
get 'feed', to: 'statuses#index', as: :feed
root to: 'statuses#index'
get '/:id', to: 'profiles#show' #This was put in as well.
This is my show.htmlerb file
<div class="page-header">
<h1><%= @user.full_name %></h1>
</div>
<% if @statuses %>
<% @statuses.each do |status| %>
<div class="well">
<%= status.content %>
<hr />
<%= link_to time_ago_in_words(status.created_at), status_path(status) %> ago
</div>
<% end %>
<% end %>
If someone sees something wrong or can help solve this problem I would appreciate it very much. Thank you in advance
1 Answer
Mikal Chawdry
5,571 PointsHi Robert,
I had the same problem. I deleted all of the users and comments on the site and created new ones. The problem disappeared.
Mikal