我是 ROR 的新手。当我单击 VIEW 中的提交按钮时,我想调用存储过程进行处理。
Model:
-------
class Pro::DataImport < ActiveRecord::Base
attr_accessible :file_name, :process_name, :updated_by, :validates
end
Controller:
-----------------
class Pro::DataImportsController < ApplicationController
before_filter :authenticate_user!
layout "layouts/enr/energy_master"
def index
@pro_data_imports = Pro::DataImport.all
end
def new
@pro_data_import = Pro::DataImport.new
end
end
View
----------
<%= form_for @pro_data_import do %>
<div class="field">
Browse the file to upload:<br />
<%= file_field_tag ':file_name' %>
</div>
<div class="actions">
<%= submit_tag 'Import File' %>
</div>
<% end %>
Stored Proc
---------------
ALTER PROCEDURE "DBA"."my_enr_test"(file_name long varchar)
BEGIN
INSERT INTO DBA.pro_data_imports(file_name) values(file_name);
END
在此先感谢..请帮助我。我想从上传按钮获取文件路径并存储到数据库列文件名中。如何执行提交按钮的存储过程。请帮我!!