[英]Routing “Following list” in Ruby on Rails
I can go to "http://localhost:3000/users/5/following" manually in my browser to see a paginated list of users I am following in my application 我可以在浏览器中手动转到“ http:// localhost:3000 / users / 5 / following”以查看我在应用程序中关注的用户的分页列表
In my Navbar, I've linked <%= link_to content_tag(:li, "Watching"), user_path(@user) %> and I get /users/5 in the URL. 在我的导航栏中,我已将<%= link_链接到content_tag(:li,“观看”),user_path(@user)%>,并且在URL中获得了/ users / 5。
What Rails syntax should I add after "user_path(@user)" to direct to /users/5/following? 我应该在“ user_path(@user)”之后添加哪种Rails语法以定向到/ users / 5 /?
My UserController for "following" looks like: 我的“跟随” UserController看起来像:
def following
@title = "Following"
@user = User.find(params[:id])
@users = @user.following.paginate(:page => params[:page])
render 'show_follow'
end
Thanks! 谢谢!
I assumed that you have following
as member in routes. 我假设您有
following
路线成员。 Then following_user_path(user_id) should do the job. 然后following_user_path(user_id)应该做的工作。 You can also run
rake routes
to inspect your routes. 您还可以运行
rake routes
来检查您的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.