簡體   English   中英

帶Rails的動作控制器錯誤

[英]Action Controller Error w/ Rails

我正在嘗試與此創建一個鏈接:

 <%= link_to "Edit Pics", edit_property_gallery_path(property, gallery) %>

我的路線是這樣的:

 edit_property_gallery GET    /properties/:property_id/galleries/:id/edit(.:format)               galleries#edit

但是我得到這個

[ 在此處輸入圖片說明 ]

而且我正在用這樣的set_gallery方法設置我的空間儀表板控制器

def set_gallery
  @gallery = Gallery.find(params[:id])
end

您能幫我看看我是怎么得到這個錯誤的。 謝謝。

以下是相關路線信息:

  resources :properties do
    collection do
      get 'search'
    end
    resources :galleries
  end

  resources :spaces do
    collection do
      get 'search'
    end
    resources :galleries do
      resources :pictures
    end

這是我的耙路輸出:

Zacharys-MBP:swing zak$ rake routes 
                        Prefix Verb   URI Pattern                                                         Controller#Action
              new_user_session GET    /users/sign_in(.:format)                                            devise/sessions#new
                  user_session POST   /users/sign_in(.:format)                                            devise/sessions#create
          destroy_user_session DELETE /users/sign_out(.:format)                                           devise/sessions#destroy
                 user_password POST   /users/password(.:format)                                           devise/passwords#create
             new_user_password GET    /users/password/new(.:format)                                       devise/passwords#new
            edit_user_password GET    /users/password/edit(.:format)                                      devise/passwords#edit
                               PATCH  /users/password(.:format)                                           devise/passwords#update
                               PUT    /users/password(.:format)                                           devise/passwords#update
      cancel_user_registration GET    /users/cancel(.:format)                                             registrations#cancel
             user_registration POST   /users(.:format)                                                    registrations#create
         new_user_registration GET    /users/sign_up(.:format)                                            registrations#new
        edit_user_registration GET    /users/edit(.:format)                                               registrations#edit
                               PATCH  /users(.:format)                                                    registrations#update
                               PUT    /users(.:format)                                                    registrations#update
                               DELETE /users(.:format)                                                    registrations#destroy
                    admin_root GET    /admin(.:format)                                                    admin/dashboard#index
               admin_dashboard GET    /admin/dashboard(.:format)                                          admin/dashboard#index
 batch_action_admin_properties POST   /admin/properties/batch_action(.:format)                            admin/properties#batch_action
              admin_properties GET    /admin/properties(.:format)                                         admin/properties#index
                               POST   /admin/properties(.:format)                                         admin/properties#create
            new_admin_property GET    /admin/properties/new(.:format)                                     admin/properties#new
           edit_admin_property GET    /admin/properties/:id/edit(.:format)                                admin/properties#edit
                admin_property GET    /admin/properties/:id(.:format)                                     admin/properties#show
                               PATCH  /admin/properties/:id(.:format)                                     admin/properties#update
                               PUT    /admin/properties/:id(.:format)                                     admin/properties#update
                               DELETE /admin/properties/:id(.:format)                                     admin/properties#destroy
     batch_action_admin_spaces POST   /admin/spaces/batch_action(.:format)                                admin/spaces#batch_action
                  admin_spaces GET    /admin/spaces(.:format)                                             admin/spaces#index
                               POST   /admin/spaces(.:format)                                             admin/spaces#create
               new_admin_space GET    /admin/spaces/new(.:format)                                         admin/spaces#new
              edit_admin_space GET    /admin/spaces/:id/edit(.:format)                                    admin/spaces#edit
                   admin_space GET    /admin/spaces/:id(.:format)                                         admin/spaces#show
                               PATCH  /admin/spaces/:id(.:format)                                         admin/spaces#update
                               PUT    /admin/spaces/:id(.:format)                                         admin/spaces#update
                               DELETE /admin/spaces/:id(.:format)                                         admin/spaces#destroy
      batch_action_admin_users POST   /admin/users/batch_action(.:format)                                 admin/users#batch_action
                   admin_users GET    /admin/users(.:format)                                              admin/users#index
                               POST   /admin/users(.:format)                                              admin/users#create
                new_admin_user GET    /admin/users/new(.:format)                                          admin/users#new
               edit_admin_user GET    /admin/users/:id/edit(.:format)                                     admin/users#edit
                    admin_user GET    /admin/users/:id(.:format)                                          admin/users#show
                               PATCH  /admin/users/:id(.:format)                                          admin/users#update
                               PUT    /admin/users/:id(.:format)                                          admin/users#update
                               DELETE /admin/users/:id(.:format)                                          admin/users#destroy
                admin_comments GET    /admin/comments(.:format)                                           admin/comments#index
                               POST   /admin/comments(.:format)                                           admin/comments#create
                 admin_comment GET    /admin/comments/:id(.:format)                                       admin/comments#show
                               DELETE /admin/comments/:id(.:format)                                       admin/comments#destroy
                      pictures GET    /pictures(.:format)                                                 pictures#index
                               POST   /pictures(.:format)                                                 pictures#create
                   new_picture GET    /pictures/new(.:format)                                             pictures#new
                  edit_picture GET    /pictures/:id/edit(.:format)                                        pictures#edit
                       picture GET    /pictures/:id(.:format)                                             pictures#show
                               PATCH  /pictures/:id(.:format)                                             pictures#update
                               PUT    /pictures/:id(.:format)                                             pictures#update
                               DELETE /pictures/:id(.:format)                                             pictures#destroy
             search_properties GET    /properties/search(.:format)                                        properties#search
            property_galleries GET    /properties/:property_id/galleries(.:format)                        galleries#index
                               POST   /properties/:property_id/galleries(.:format)                        galleries#create
          new_property_gallery GET    /properties/:property_id/galleries/new(.:format)                    galleries#new
         edit_property_gallery GET    /properties/:property_id/galleries/:id/edit(.:format)               galleries#edit
              property_gallery GET    /properties/:property_id/galleries/:id(.:format)                    galleries#show
                               PATCH  /properties/:property_id/galleries/:id(.:format)                    galleries#update
                               PUT    /properties/:property_id/galleries/:id(.:format)                    galleries#update
                               DELETE /properties/:property_id/galleries/:id(.:format)                    galleries#destroy
                    properties GET    /properties(.:format)                                               properties#index
                               POST   /properties(.:format)                                               properties#create
                  new_property GET    /properties/new(.:format)                                           properties#new
                 edit_property GET    /properties/:id/edit(.:format)                                      properties#edit
                      property GET    /properties/:id(.:format)                                           properties#show
                               PATCH  /properties/:id(.:format)                                           properties#update
                               PUT    /properties/:id(.:format)                                           properties#update
                               DELETE /properties/:id(.:format)                                           properties#destroy
                 search_spaces GET    /spaces/search(.:format)                                            spaces#search
        space_gallery_pictures GET    /spaces/:space_id/galleries/:gallery_id/pictures(.:format)          pictures#index
                               POST   /spaces/:space_id/galleries/:gallery_id/pictures(.:format)          pictures#create
     new_space_gallery_picture GET    /spaces/:space_id/galleries/:gallery_id/pictures/new(.:format)      pictures#new
    edit_space_gallery_picture GET    /spaces/:space_id/galleries/:gallery_id/pictures/:id/edit(.:format) pictures#edit
         space_gallery_picture GET    /spaces/:space_id/galleries/:gallery_id/pictures/:id(.:format)      pictures#show
                               PATCH  /spaces/:space_id/galleries/:gallery_id/pictures/:id(.:format)      pictures#update
                               PUT    /spaces/:space_id/galleries/:gallery_id/pictures/:id(.:format)      pictures#update
                               DELETE /spaces/:space_id/galleries/:gallery_id/pictures/:id(.:format)      pictures#destroy
               space_galleries GET    /spaces/:space_id/galleries(.:format)                               galleries#index
                               POST   /spaces/:space_id/galleries(.:format)                               galleries#create
             new_space_gallery GET    /spaces/:space_id/galleries/new(.:format)                           galleries#new
            edit_space_gallery GET    /spaces/:space_id/galleries/:id/edit(.:format)                      galleries#edit
                 space_gallery GET    /spaces/:space_id/galleries/:id(.:format)                           galleries#show
                               PATCH  /spaces/:space_id/galleries/:id(.:format)                           galleries#update
                               PUT    /spaces/:space_id/galleries/:id(.:format)                           galleries#update
                               DELETE /spaces/:space_id/galleries/:id(.:format)                           galleries#destroy
       evaluate_space_contract GET    /spaces/:space_id/contracts/:id/evaluate(.:format)                  contracts#evaluate
tenant_evaluate_space_contract GET    /spaces/:space_id/contracts/:id/tenant_evaluate(.:format)           contracts#tenant_evaluate
               space_contracts GET    /spaces/:space_id/contracts(.:format)                               contracts#index
                               POST   /spaces/:space_id/contracts(.:format)                               contracts#create
            new_space_contract GET    /spaces/:space_id/contracts/new(.:format)                           contracts#new
           edit_space_contract GET    /spaces/:space_id/contracts/:id/edit(.:format)                      contracts#edit
                space_contract GET    /spaces/:space_id/contracts/:id(.:format)                           contracts#show
                               PATCH  /spaces/:space_id/contracts/:id(.:format)                           contracts#update
                               PUT    /spaces/:space_id/contracts/:id(.:format)                           contracts#update
                               DELETE /spaces/:space_id/contracts/:id(.:format)                           contracts#destroy
                 space_reviews GET    /spaces/:space_id/reviews(.:format)                                 reviews#index
                               POST   /spaces/:space_id/reviews(.:format)                                 reviews#create
              new_space_review GET    /spaces/:space_id/reviews/new(.:format)                             reviews#new
             edit_space_review GET    /spaces/:space_id/reviews/:id/edit(.:format)                        reviews#edit
                  space_review GET    /spaces/:space_id/reviews/:id(.:format)                             reviews#show
                               PATCH  /spaces/:space_id/reviews/:id(.:format)                             reviews#update
                               PUT    /spaces/:space_id/reviews/:id(.:format)                             reviews#update
                               DELETE /spaces/:space_id/reviews/:id(.:format)                             reviews#destroy
                        spaces GET    /spaces(.:format)                                                   spaces#index
                               POST   /spaces(.:format)                                                   spaces#create
                     new_space GET    /spaces/new(.:format)                                               spaces#new
                    edit_space GET    /spaces/:id/edit(.:format)                                          spaces#edit
                         space GET    /spaces/:id(.:format)                                               spaces#show
                               PATCH  /spaces/:id(.:format)                                               spaces#update
                               PUT    /spaces/:id(.:format)                                               spaces#update
                               DELETE /spaces/:id(.:format)                                               spaces#destroy
                          root GET    /                                                                   spaces#index
                       payment GET    /payment(.:format)                                                  contracts#payment
                     dashboard GET    /dashboard(.:format)                                                spaces#dashboard
                      about_us GET    /about_us(.:format)                                                 marketing_pages#about_us
                          team GET    /team(.:format)                                                     marketing_pages#team
                  how_it_works GET    /how_it_works(.:format)                                             marketing_pages#how_it_works
                         users GET    /users(.:format)                                                    users#index
                               POST   /users(.:format)                                                    users#create
                      new_user GET    /users/new(.:format)                                                users#new
                     edit_user GET    /users/:id/edit(.:format)                                           users#edit
                          user GET    /users/:id(.:format)                                                users#show
                               PATCH  /users/:id(.:format)                                                users#update
                               PUT    /users/:id(.:format)                                                users#update
                               DELETE /users/:id(.:format)                                                users#destroy
                      messages GET    /messages(.:format)                                                 redirect(301, /conversations)
                       message POST   /messages/:id(.:format)                                             messages#new
                               GET    /messages(.:format)                                                 messages#index
                               POST   /messages(.:format)                                                 messages#create
                   new_message GET    /messages/new(.:format)                                             messages#new
                  edit_message GET    /messages/:id/edit(.:format)                                        messages#edit
                               GET    /messages/:id(.:format)                                             messages#show
                               PATCH  /messages/:id(.:format)                                             messages#update
                               PUT    /messages/:id(.:format)                                             messages#update
                               DELETE /messages/:id(.:format)                                             messages#destroy
            reply_conversation POST   /conversations/:id/reply(.:format)                                  conversations#reply
            trash_conversation POST   /conversations/:id/trash(.:format)                                  conversations#trash
          untrash_conversation POST   /conversations/:id/untrash(.:format)                                conversations#untrash
        trashbin_conversations GET    /conversations/trashbin(.:format)                                   conversations#trashbin
     empty_trash_conversations POST   /conversations/empty_trash(.:format)                                conversations#empty_trash
                 conversations GET    /conversations(.:format)                                            conversations#index
                               POST   /conversations(.:format)                                            conversations#create
              new_conversation GET    /conversations/new(.:format)                                        conversations#new
             edit_conversation GET    /conversations/:id/edit(.:format)                                   conversations#edit
                  conversation GET    /conversations/:id(.:format)                                        conversations#show
                               PATCH  /conversations/:id(.:format)                                        conversations#update
                               PUT    /conversations/:id(.:format)                                        conversations#update
                               DELETE /conversations/:id(.:format)                                        conversations#destroy

似乎您應該通過以下方式調用您的url幫助器:

edit_property_gallery_path(gallery, property_id: property.id)

您的galleryproperty參數已切換,我認為您不能將property用作第二個參數,哈希肯定可以工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM