ruby on rails -打印HTML页面Twitter引导



我有一个show page/invoices/show来显示我的Invoice

<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:&nbsp; <%= @invoice.id  %></div>
                <div style="float:right"> Date:&nbsp; <%= @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" %>

更重要的是,我的应用程序文件有一个导航栏元素。

我正在尝试打印发票/show.html。但是,我不希望它包括application.html.erb文件中的nav-bar元素和发票/show.html中的编辑按钮。

我正在使用Twitter bootstrap,我该怎么做?

我想到了一个解决方案:

你可以做的是,在你的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

相关内容

  • 没有找到相关文章

最新更新