我想创建一个名为 Database Importer 的控制器。
这是我跑的:
rails generate controller database_importer index
这产生了:
class DatabaseImporterController < ApplicationController
def index
end
def import
# to do.
# Receive the uploaded CSV file and import to the database.
CSV.foreach("parse.csv") do |row|
end
end
end
当我访问时,http://0.0.0.0:3000/database_importer/index
我得到:
Routing Error
No route matches {:action=>"import", :controller=>"database_importer"}
Try running rake routes for more information on available routes.
这是我的相关路线:
get 'database_importer/index'
为什么路由引擎试图将我推向导入操作方法?
当我尝试更改路由以反映实际的控制器名称(它没有下划线)时,我得到:
get 'databaseimporter/index'
Routing Error
uninitialized constant DatabaseimporterController
Try running rake routes for more information on available routes.