我想创建一个名为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'
为什么路由引擎试图将我推向import action方法?
当我试图改变路由,以反映实际的控制器名称(它没有下划线),我得到:
get 'databaseimporter/index'
Routing Error
uninitialized constant DatabaseimporterController
Try running rake routes for more information on available routes.
您是否也有这样定义的路由:
post 'database_importer/import'
我认为当Rails试图为表单生成路由时,表单动作是失败的