Linking to profile page by username on Ruby -


what want able when clicks on picture see user uploaded pictures username , want them able click username , go persons profile page.

here issue have working first post. have multiple users , posts show correct username each one. links fine. post after throws error , user id gets higher each post.

this profile page posts know user posts these pics. , when click first picture , username correctly takes me here.

enter image description here

now when click 2nd picture this. , if click 3rd pic couldn't find user "id"=2. though post recognizes posted pic having correct username.

enter image description here

this code have on show posts

<div class="panel-body">      <p><strong><%= link_to(@post.user.username.capitalize, user_path) if @post.user %></strong></p>     <p><%= @post.description %></p>     <% if @post.user == current_user %>      <%= link_to 'edit', edit_post_path(@post) %>     <% end %>    </div> 

again works fine 1st upload if guys need see more code gladly upload it

could try ? ( user_path(@post.user.id) )

<p><strong><%= link_to(@post.user.username.capitalize, user_path(@post.user.id)) if @post.user %></strong></p> 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)