2016-09-06 149 views
2

我使用回形针上传文件(仅限PDF),现在想在视图中将它们显示为PDF。显示使用回形针上传的PDF文件

这给了我一个空架<iframe src="<% @document.file %>"></iframe> 这导致图像<%= image_tag @document.file(:large) %>

的文件存储在postgress英寸

+0

试过了 - iframe的空 –

回答

2

你有一个语法中的 “问题”:

<iframe src="<% @document.file %>"></iframe> 

应该

<iframe src="<%= @document.file %>"></iframe> 
<!-- notice the equals symbol (=) --> 
<!-- which prints something into erb file. --> 

而且,我相信你需要使用它的url,所以我想是这样的:

<iframe src="<%= @document.file.url(:large) %>"></iframe> 

更多信息 - What is the difference between <%, <%=, <%# and -%> in ERB in Rails?

+0

谢谢;意识到差异但忘记使用它(RoR新增功能)。 –