我有一个显示页面/发票/节目,显示我的发票的内容
<p id="notice"><%= notice %></p>
<div class="row">
<div class="span7">
<h2 style="text-align:center;"> CONSTRUCTION LTD </h2>
<h3 style="text-align:center;">OHIO</h3>
<address style="text-align:center;"> Plot 10<br/>
</address>
<h3 style="text-decoration:underline; text-align:center;"> UTILITY BILL </h3>
<h4 style="text-decoration:underline; text-align:center;"> TAX INVOICE </h4>
<table>
<td valign="top" align="left">
<div style="float:left; width:450px;">No: <%= @invoice.id %></div>
<div style="float:right"> Date: <%= @invoice.invoice_date %></div>
</td>
</table>
<P></P>
<P></P>
<div>To: <%= @invoice.customer.name%></div>
<p></p>
<table class="table table-bordered table-condensed">
<thead>
<tr class="success">
<th><label class="control-label">Description</label></th>
<th><label class="control-label">Rate</label></th>
<th><label class="control-label">Tax</label></th>
<th><label class="control-label">Amount</label></th>
</tr>
</thead>
<tbody>
<% @invoice.invoice_items.each do | item| %>
<tr class="controls">
<td><%= item.description %></td>
<td><%= item.rate %></td>
<td><%= item.tax_amount %></td>
<td><%= item.amount %></td>
</tr>
<tr>
<td colspan="3" align="left"><strong>TOTAL:</strong></td>
<td colspan="1"><%= item.amount %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="row">
<div class="span3">
<table>
<tbody>
<tr>
<td> <b>For Landlord</b></td></tr>
<tr> <td>Approved by:</td></tr>
<tr> <td>Sign:</td></tr>
</tbody>
</table>
</div>
<div class="span3" style="position: relative; align:left; left:150px;">
<table>
<tbody>
<tr>
<td> <b>For Tenant</b></td></tr>
<tr> <td>Approved by:</td></tr>
<tr> <td>Sign:</td></tr>
</tbody>
</table>
</div>
</div>
<br/>
<br />
<div>
<small><strong>Terms and Conditions</strong></small>
<table>
<tbody>
<tr>
<td><%= Settings.invoice_terms%></td>
</tr>
</tbody>
</table>
</div>
<br />
<div class="form actions">
<p>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_invoice_path, :class => 'btn btn-primary' %>
</p>
</div>
</div>
</div>
在我的application.html.erb中,我有这个用于CSS
<%= stylesheet_link_tag "application", :media => "all" %>
更多的是,我的应用程序文件有一个导航栏元素。
我正在尝试通过浏览器中的print选项打印Invoices / show.html.erb页面,但是,我不希望它在我的application.html.erb文件中包含nav-bar元素,发票/ show.html中的编辑按钮。
我正在使用Twitter bootstrap,我该如何解决这个问题?
答案 0 :(得分:0)
这是我想到的一个解决方案:
您可以在show
视图(或应用程序布局)中添加谓词:
if params[:controller] == "invoice" && params[:action] == "show"
# do or show whatever you want
end
或者您可以为views/layouts
文件夹添加不同的布局。然后在controllers/invoice_controller
def show
# ...
render layout: 'a_different_layout_for_invoices'
end