我有一个 html 文件如下,位于views/admin/ve_files/new.html.erb
<div class="page-header">
<h3>Hi</h3>
</div>
<%= simple_form_for @ve_file do |f| %>
<%= f.file_field :file %>
<br><br>
<%= f.submit "Upload" %>
<% end %>
<br>
然后我有一个控制器,controllers/admin/ve_files_controller.rb
它看起来像这样
require 'CSV'
class Admin::VeFilesController < ApplicationController
layout 'admin'
def new
authorize! :create, :ve_file
@ve_file = VeFile.new
end
def create
puts "hello"
authorize! :create, :ve_file
#puts params
@ve_file = VeFile.new(params[:ve_file])
puts "okay"
if @ve_file.save
CSV.foreach(@ve_file.file.path) do |row|
puts row[0]
end
redirect_to admin_ve_path, :notice => 'Hi'
else
render :new
end
end
end
因此,当我单击 html 文件中的上传按钮时,程序会尝试将我路由到哪里?代码在哪里指定?我收到以下错误,终端没有输出:
Routing Error
uninitialized constant VeFilesController
因为它应该是Admin::VeFilesController