Authentication with devise and a separate controller (Users) that is a single 'show' action
class UsersController < ApplicationController
#before_filter :authenticate_user!
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
end
So far the view (users/show.html.erb) only displays the username of the accessed profile
<%= @user.username %>
Routing also:
resources :users
I would like these profile pages to be publically accessible if they get a link to it/told the address, but also want a link available to a currently logged in user to visit his profile. My a snippet from my header:
<li><%= link_to "Profile", @user %></li>
<li><%= link_to "Settings", edit_user_registration_path %></li>
<li><%= link_to "Logout", destroy_user_session_path, method: "delete" %></li>
Currently, @user is just there to stop a routing error. I'm not entirely sure what to link to, have tried quite a few combinations but obviously my rails newbie mind is missing something extra I need to do. Any help is much appreciated!
(Rails 4, ruby 2.0.0)
Side note I would also like to, eventually, allow the link to a profile page to display the id + username in the format: #{id}-#{username} (instead of just being users/1 --> users/1-bbvoncrumb).