Rails 视图未渲染
视图:
<% form_tag(:action => 'create', :multipart => true) do %>
Select CSV File:
<%= file_field_tag 'data' %>
<br/><br/>
<%= submit_tag 'Upload' %>
<% end %>
控制器:
class UploadController < ApplicationController
def index
respond_to do |format|
format.html {render :layout => false}
end
end
def create
DataFile.save(params[:data])
respond_to do |format|
render :text => "File has been uploaded"
# format.html { redirect_to :back }
end
end
end
当我去上传/新建时,没有任何内容呈现 - 只是一个空白页面。如果我将内容放在 form_tag
之外的视图中,那么它会正确呈现。
View:
<% form_tag(:action => 'create', :multipart => true) do %>
Select CSV File:
<%= file_field_tag 'data' %>
<br/><br/>
<%= submit_tag 'Upload' %>
<% end %>
Controller:
class UploadController < ApplicationController
def index
respond_to do |format|
format.html {render :layout => false}
end
end
def create
DataFile.save(params[:data])
respond_to do |format|
render :text => "File has been uploaded"
# format.html { redirect_to :back }
end
end
end
When I go to upload/new nothing is rendered - just a blank page. If I put content in the view outside of the form_tag
then it is rendered correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Rails 3 的 ERB 中,使用等号输出块的内容:
In ERB in Rails 3, use an equals sign to output the contents of a block: