加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – ActionController :: UrlGenerationError:没

发布时间:2020-12-16 23:10:10 所属栏目:百科 来源:网络整理
导读:我从行%= link_to“询问用户输出”,askout_user_message_path(@user),:class =行收到无路由匹配错误“按钮”%. 这曾经在我添加宝石之前工作,但现在它停止了工作.我尝试在收集下移动,但我没有运气,因为那是以前的地方. 路线: resources :users do |user|
我从行<%= 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视图中确定 – 您应该查看它以了解您的路由被调用(允许您相应地编写它)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读