简体   繁体   中英

uploading and import csv to rails

i have followed this tut enter link description here , though i seem to have encountered a few issues. the problem i am getting is

NameError

undefined local variable or method `map' for #<ActionDispatch::Routing::Mapper:0x007f81b1bd0170>

which i believe is related to the routes.rb

map.resources :imports
  map.import_proc '/import/proc/:id', :controller => "imports", :action => "proc_csv"

im using Ruby 1.9.3, Rails 3.2.3

map is the keyword used for routing in Rails 2. Rails 3 routing is substantially changed. You want something more like this:

resources :imports do
  member do
    get :import_proc
  end
end

For more information, check out the Rails routing guide .

import_proc is a member method so you need to pass in a parameter

import_proc_path(id)

Member methods require a parameter, an ID Collection methods does not require a parameter so it doesn't require a parameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM