Ruby on rails 路由问题

Ruby on rails 路由问题,ruby-on-rails,Ruby On Rails,我有两个以相同方式路由的相同控制器: 这是控制器 class ProfileController < ApplicationController def index @text = "profile" end def show end def new end def create end def edit end def update end def destroy end end class FriendsController < ApplicationCont

我有两个以相同方式路由的相同控制器:

这是控制器

class ProfileController < ApplicationController



def index
@text = "profile"
end
def show
end
def new 
end
def create
end
def edit
end
def update
end
def destroy
end

end





class FriendsController < ApplicationController


def index
@text = "friends"
end
def show

end
def new 
end
def create
end
def edit
end
def update
end
def destroy
end

end
如果控制器和视图相同,为什么会发生这种情况?

尝试使用

<%= link_to "Profile", profiles_path %>

不同之处在于变量名配置文件s\u路径。因为指向索引url的路径应该是复数形式


通过运行rake routes,您还可以查看应用程序中的所有路由。这是调试路由问题的一个实时保护程序。

这与您为概要文件控制器指定了一个单数名称和路由有关。您可以运行
rake routes
,以了解路由助手的名称。查找
GET/profile
,它可能类似于
index\u profile\u path
profile\u index\u path


编辑:更具体地说,错误是因为默认情况下,
profile\u path
将作为显示某个实例的帮助器,例如,
profile\u path(@profile)

不是这样。。我以前试过,现在也试过。我得到了错误:未定义的局部变量或#的“profiles_path”方法,所以我认为这不是问题所在
<ul id="menu">

<li>
<%= link_to "Friends",friends_path %>
</li>
<li>
<%= link_to "Profile", profile_path %>
</li>


</ul>
No route matches {:action=>"show", :controller=>"profile"}
<%= link_to "Profile", profiles_path %>