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) %>