您好,我的 rake 路由中的索引似乎没有正确显示,这有点问题
我已经像这样在我的 Controller 模块中定义了索引
def index
@user_friendship = current_user.user_friendships.all
end
我还在 View 中将其定义为 index.html.erb
但我的问题是它现在显示在我的 rake route 这是我唯一得到的
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
如您所见,它没有显示在我的 rake route
这是我的 routes.rb 代码
resource :user_friendships do
member do
put :accept
end
end
如果你们能帮我解决这个问题,那就太好了教程似乎有点老了,再次感谢!
最佳答案
默认情况下resource
不创建索引 Action 。你应该使用 resources
:
resources :user_friendships do
member do
put :accept
end
end
关于ruby-on-rails - rails 4.1.6 在似乎未显示的 rake route 添加索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27797674/