저는 레일즈 플랫폼의 루비에 초보자이며 몇 가지 예제 코드를 사용해 보았습니다. 나는 모든 지침을 따랐이 예 http://goodbadtech.com/2009/05/13/ruby-on-rails-import-csv-data-into-database/ 를 실행하려고했지만, 난이 오류를루비와 레일에서 csv 파일을 파싱 할 수 없습니다.
ActionController :: RoutingError (초기화되지 않은 상수 CsvImportController)를 얻고 :
날이 오류를 비난하기 위해 도와주세요.
다음은 클래스 CsvImportsController
가 csv_imports_controller
이름을 지정해야합니다 포함, 내 Routes.rb
Imports::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
get "csv_imports/csv_view"
#map.resources :imports
#map.import_proc '/import/proc/:id', :controller => "imports", :action => "proc_csv"
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
resources :imports
import_proc '/import/proc/:id', :controller => "csv_imports", :action => "pro_csv"
end
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'csv_imports#csv_view'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
레일'CsvImportController'을 찾고있다 (또한 언급 블로그 게시물 레일 3 레일이 아니라위한주의),하지만 난 당신이 CSVImportController 그것을라고 가정합니다. 이름을 변경하면 문제가 사라질 수 있습니다. – Wukerplank
@Wukerplank : routes.rb 파일에서 의미가 있습니까? –
아니요, 저는 이것이 컨트롤러를 말하는 것이라고 생각합니다. 'app/controllers/csv_import_controller.rb' 파일을 살펴보십시오. 수업 이름이 뭐니? – Wukerplank