Ruby on rails rails 4.1.6在似乎未显示的rake路由中添加索引
嗨,我有点问题,因为索引似乎没有在我的rake路由中正确显示 我在控制器模块中定义了索引,如下所示Ruby on rails rails 4.1.6在似乎未显示的rake路由中添加索引,ruby-on-rails,controller,routes,ruby-on-rails-4.1,Ruby On Rails,Controller,Routes,Ruby On Rails 4.1,嗨,我有点问题,因为索引似乎没有在我的rake路由中正确显示 我在控制器模块中定义了索引,如下所示 def index @user_friendship = current_user.user_friendships.all end 我还在视图中将其定义为index.html.erb 但我的问题是,它现在显示在我的耙路线,这是我唯一得到的 accept_user_friendships PUT /user_friendships/accept(.:format)
def index
@user_friendship = current_user.user_friendships.all
end
我还在视图中将其定义为index.html.erb
但我的问题是,它现在显示在我的耙路线,这是我唯一得到的
accept_user_friendships PUT /user_friendships/accept(.:format) user_friendships#accept
user_friendships POST /user_friendships(.:format) user_friendships#create
new_user_friendships GET /user_friendships/new(.:format) user_friendships#new
edit_user_friendships GET /user_friendships/edit(.:format) user_friendships#edit
GET /user_friendships(.:format) user_friendships#show
PATCH /user_friendships(.:format) user_friendships#update
PUT /user_friendships(.:format) user_friendships#update
DELETE /user_friendships(.:format) user_friendships#destroy
正如你所看到的,它没有显示在我的耙路线
这是我的routes.rb代码
resource :user_friendships do
member do
put :accept
end
end
如果你们能帮我解决这个问题,那也太好了。请注意,我是rails的初学者,刚刚学习了我朋友给我的一个教程,所以我在修复教程中出现的错误时遇到了麻烦,这个错误看起来有点旧,再次感谢 默认情况下
资源
不创建索引操作。您应该使用资源
:
resources :user_friendships do
member do
put :accept
end
end
尝试使用
资源
而不是资源
<代码>资源默认情况下不会创建索引操作,相反,您可以明确地将其告知ie。仅限资源:[:索引,:显示,:编辑]
您好,感谢您的修复,现在它正在工作!谢谢你提供更多信息的链接!