我是 Ruby on Rails 的新手,不断收到以下错误消息:
ActionController::RoutingError in Users#index
"No route matches {:action=>"following", :controller=>"users"}"
Showing /app/views/layouts/_navbar.html.erb......where line #19 raised:
Extracted source (around line #19):
16: </td>
17: </div>
18:
19: <div id="secondlink"><td class="rite"><li><% if signed_in? %><%= link_to "Profile", current_user %></li><li><%= link_to "watching", following_user_path(@user)%></li><li><%= link_to "Users", users_path %></li><li><%= link_to "Sign out", signout_path, :method => :delete %>
20: <% else %>
21: <%= link_to "Sign in", signin_path %></li><% end %>
22:
当我单击链接(在我的导航栏中)以显示分页用户的完整列表时,会发生此路由错误”
我的 routes.rb 文件中包含以下内容:
Mvp::Application.routes.draw do
resources :users do
member do
get :following, :followers
end
end
UsersController 中的“以下”操作:
def following
@title = "Following"
@user = User.find(params[:id])
@users = @user.following.paginate(:page => params[:page])
render 'show_follow'
end