dsu1/Archivist

Navbar Username to Link to User Show Action

Closed this issue · 1 comments

dsu1 commented

The Navbar's Username links to the User Index action which should instead link to the User Show Action.

dsu1 commented

layouts/application.html.erb

The problem was the link_to for usernames was using users_path which routes through Users Index. I changed the path to route through Users Show by changing it to user_path and passing it the user id via current_user.id

<% if current_user %>
	<li><%= link_to "#{current_user.username}", user_path(current_user.id) %></li>

Users Controller Show action

Was using the username for fetching Users but then I changed to using the user id:
@user = User.find(user_id_params[:id])
Maybe I should use usernames for retrieving users (I think it was a recommend security practice?) but for now everything will be user ids.

views/users/show.html.erb

Just rendering the archives partial. At the moment I'm conflicted on what to place in the user's home page so for now it's just going to be archives. Maybe later on I'll add friends, metrics, and saved preferences/settings.

<% if current_user %>
	<% if @archives.nil? %>
		...
	<% else %>
		<%= render partial: "archives/archives", collection: @archives %>
	<% end %>