Note that there are some explanatory texts on larger screens.

plurals
  1. POUser profile pages with devise - Routing to show action
    primarykey
    data
    text
    <p>Authentication with devise and a separate controller (Users) that is a single 'show' action</p> <pre><code>class UsersController &lt; 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 =&gt; @user } end end end </code></pre> <p>So far the view (users/show.html.erb) only displays the username of the accessed profile</p> <pre><code>&lt;%= @user.username %&gt; </code></pre> <p>Routing also:</p> <pre><code>resources :users </code></pre> <p>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:</p> <pre><code>&lt;li&gt;&lt;%= link_to "Profile", @user %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= link_to "Settings", edit_user_registration_path %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= link_to "Logout", destroy_user_session_path, method: "delete" %&gt;&lt;/li&gt; </code></pre> <p>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!</p> <p>(Rails 4, ruby 2.0.0)</p> <p><em>Side note</em> 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).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload