2013-01-07 95 views
1

我有一個節目頁/發票/顯示顯示我的發票打印HTML頁面Twitter的引導

<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" %> 

更重要的是,我的應用程序文件有一個導航欄元素。

我試圖通過打開瀏覽器中的打印選項來打印Invoices/show.html.erb頁面,但是,我不希望它包含導航欄元素在我的application.html.erb文件中和invoices/show.html中的編輯按鈕。

我正在使用Twitter引導程序,我該如何解決這個問題?

回答

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 
+0

我實際上做的是在我的控制器中添加一個打印操作並將佈局設置爲false。在視圖中,我所做的只是內聯樣式和瓦拉....它的工作 – zurik