Rails中未定义的_path错误

时间:2014-09-08 06:35:44

标签: ruby-on-rails ruby-on-rails-4

我看过很多类似的问题,但我仍然无法解决此错误:

undefined local variable or method `import_home_path' for #<#<Class:0x007fdcf7810ca0>:0x007fdcf7813108>

继承路线档案:

resources :home do
    collection { post :import}
end

继承耙路线:

           Prefix Verb   URI Pattern              Controller#Action
import_home_index POST   /home/import(.:format)   home#import
       home_index GET    /home(.:format)          home#index
                  POST   /home(.:format)          home#create
         new_home GET    /home/new(.:format)      home#new
        edit_home GET    /home/:id/edit(.:format) home#edit
             home GET    /home/:id(.:format)      home#show
                  PATCH  /home/:id(.:format)      home#update
                  PUT    /home/:id(.:format)      home#update
                  DELETE /home/:id(.:format)      home#destroy
        home_test GET    /home/test(.:format)     home#test

继承了调用import_home_path

的show.html.erb
<%= form_tag import_home_path, multipart: true do %>
  <%= file_field_tag :file %>
  <%= submit_tag "Import CSV" %>
<% end %>

我只想尝试使用tutorial here进行简单测试。但偶然发现了有名的助手。

1 个答案:

答案 0 :(得分:1)

根据路线,您的路径为import_home_index_path,而不是import_home_path