【发布时间】:2014-02-28 03:11:36
【问题描述】:
在我的控制器中我这样编码
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)
如何呈现索引操作和查看索引文件内容。
【问题讨论】:
-
尝试在 create 方法中将渲染更改为 redirect_to。
-
只是想知道,为什么您不想在创建操作完成后重定向回索引页面?
redirect_to company_upload_requests_path
标签: ruby-on-rails