我从行<%= link_to“询问用户输出”,askout_user_message_path(@user),:class =>行收到无路由匹配错误“按钮”%>.
这曾经在我添加宝石之前工作,但现在它停止了工作.我尝试在收集下移动,但我没有运气,因为那是以前的地方.
路线:
resources :users do |user| resources :messages do member do post :new get 'askout',action: 'askout' end end collection do get :trashbin post :empty_trash end end resources :conversations do member do post :reply post :trash post :untrash end end
旧路线:
resources :users do |user| resources :messages do collection do post 'delete_multiple' get 'askout',action: 'askout' get 'reply',action: 'reply' end end end
当我添加邮箱gem时,我的路线发生了变化.
解决方法
你最好这样做:
#config/routes.rb resources :users do resources :messages do member do post :new get :askout end end collection do get :trashbin post :empty_trash end end
这会给你:
users/1/messages/5/askout
我想你想要什么:
#config/routes.rb resources :users do resources :messages do post :new collection do get :askout end end collection do get :trashbin post :empty_trash end end
这会给你:
users/2/messages/askout
路径助手将在rake routes视图中确定 – 您应该查看它以了解您的路由被调用(允许您相应地编写它)