Answer the question
In order to leave comments, you need to log in
How to add _path to own url?
Added controller
to routes.rb :get 'userposts/:id', to: 'posts#userposts'
def userposts
@user = User.find(params[:id])
@posts = Post.where(user_id: @user.id).order('created_at DESC')
end
GET /userposts/:id(.:format) posts#userposts
<%= link_to "my posts", userposts_path(current_user.id) %>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question