在我的控制器中,我这样编码
class CompanyUploadRequestsController < ApiController
def index
respond_to do |format|
format.html { render action: "index" }
end
end
def create
puts params
respond_to do |format|
format.html { render action: "index" }
end
end
def new
end
end
并在我看来new.html.haml
档案
- page_title("Upload Company")
%h1 Upload Company
%hr
#upload-form
= simple_form_for(@company_upload, :as => :company_update, :url => company_upload_requests_path(@company_upload), :html => { :class => 'file-style'}) do |f|
= f.error_notification
.form-inputs
= f.input :requestname, :label => false, :id => "request_name_input"
= f.input :file,:as => :file, :label => false, :id => "file_select_input"
.form-actions
!= link_to 'Cancel', company_upload_requests_path, :class => 'btn'
= f.button :submit, 'Upload', :class => 'btn-primary'
在我的index.html.haml
文件中,我有这个
- page_title("Upload Company")
%h1 Company index
= link_to("Upload File", new_company_upload_request_path, :class => "btn btn-primary pull-right")
问题是当我点击上传按钮时,它不会从创建
渲染到索引页面我在这里得到了这样的日志
Processing by CompanyUploadRequestsController#create as HTML
Parameters: {"utf8"=>"?", "authenticity_token"=>"oygIP62E4GHefhN9OnvB3sKhddIb4CN/izfvF5GQtuI=", "company_update"=>{"requestname"=>""}, "commit"=>"Upload"}
Rendered company_upload_requests/create.html.haml within layouts/application (9.8ms)
如何呈现索引操作并查看索引文件内容。
答案 0 :(得分:1)
像这样使用。
def index
@company_uploads = ModelName.all
respond_to do |format|
format.html
end
end
无需在索引响应中呈现索引操作。
def create
puts params
respond_to do |format|
format.html { render "index" }
end
end
答案 1 :(得分:0)