resting
resting

Reputation: 17467

Undefined _path error in Rails

I'd seen many similar questions but I still can't resolve this error:

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

Heres the route file:

resources :home do
    collection { post :import}
end

Heres the rake routes:

           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

Heres the show.html.erb that calls import_home_path

<%= form_tag import_home_path, multipart: true do %>
  <%= file_field_tag :file %>
  <%= submit_tag "Import CSV" %>
<% end %>

I'm just trying to do a simple test with the tutorial here. But stumbled in named helpers.

Upvotes: 0

Views: 116

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52357

According to routes your path would be import_home_index_path, not import_home_path.

Upvotes: 1

Related Questions