日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
RubyonRails列表頁面如何進(jìn)行優(yōu)化

Ruby on Rails列表頁面可以被我們進(jìn)行優(yōu)化。美化后的列表頁面可以幫助我們一目了然的讀懂列表,方便我們編寫程序。在這里我們將會(huì)介紹Ruby on Rails列表頁面的一些美化技巧。#t#

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供本溪網(wǎng)站建設(shè)、本溪做網(wǎng)站、本溪網(wǎng)站設(shè)計(jì)、本溪網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、本溪企業(yè)網(wǎng)站模板建站服務(wù),十載本溪做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

1.  打開appviewsadminlist.rhtml文件,可以看到下面的代碼

  1. <h1>Listing products</h1>
  2. <table>
  3. <tr>
  4. <% for column in Product.content_columns %>
  5. <th>< %= column.human_name %>< /th>
  6. <% end %>
  7. </tr>
  8. <% for product in @products %>
  9. <tr>
  10. <% for column in Product.content_columns %>
  11. <%=h product.send(column.name) %>
  12. <% end %>
  13. <%= link_to 'Show', :action => 'show',
     :id => product %>
  14. <%= link_to 'Edit', :action => 'edit', 
    :id => product %>
  15. <%= link_to 'Destroy', { :action => 
    'destroy', :id => product }, :confirm => 
    'Are you sure?', :method => :post %>
  16. <% end %>
  17. <%= link_to 'Previous page', { :page =>
     @product_pages.current.previous } if 
    @product_pages.current.previous %>
  18. <%= link_to 'Next page', { :page => 
    @product_pages.current.next } if 
    @product_pages.current.next %>
  19.  />
  20. <%= link_to 'New product', :action => 'new' %>

可以看到,list頁面實(shí)際上是對(duì)Products做循環(huán),然后對(duì)每行,每列逐個(gè)輸出到一個(gè)Table中,而link_to函數(shù),我們?cè)谇懊娴膬?nèi)容中也使用過。

Ruby on Rails列表頁面2.修改appviewsadminlist.rhtml的內(nèi)容,如下:

 
 
 
  1. Product Listing

  2. <%
  3. odd_or_even = 0
  4. for product in @products
  5. odd_or_even = 1 - odd_or_even
  6. %>
  7. ListLine<%= odd_or_even %>">
  8. <%= product.image_url %>"/>
  9. <%=
     h(product.title) %>
  10. <%= h(truncate(product.description, 80)) %>
  11. <%= product.date_available.strftime
    ("%y-%m-%d") %>
  12. $<%= sprintf("%0.2f", 
    product.price) %>
  13. <%= link_to 'Show', :action => 'show', 
    :id => product %>
  14. <%= link_to 'Edit', :action => 'edit', 
    :id => product %>
  15. <%= link_to 'Destroy', { :action => 
    'destroy', :id => product },
  16. :confirm => "Are you sure?" %>
  17. <% end %>
  18. <%= if @product_pages.current.previous
  19. link_to("Previous page", { :page => 
    @product_pages.current.previous })
  20. end
  21. %>
  22. <%= if @product_pages.current.next
  23. link_to("Next page", { :page =>
     @product_pages.current.next })
  24. end
  25. %>
  26. <%= link_to 'New product', :action => 'new' %>

Ruby on Rails列表頁面3.在上面的代碼里,我們可以看到td class="ListActions"這樣的代碼,下來我們添加這些css樣式的內(nèi)容:

將下面的內(nèi)容添加到publicstylesheets scaffold.css文件中:

 
 
 
  1. .ListTitle {
  2. color: #244;
  3. font-weight: bold;
  4. font-size: larger;
  5. }
  6. .ListActions {
  7. font-size: x-small;
  8. text-align: right;
  9. padding-left: 1em;
  10. }
  11. .ListLine0 {
  12. background: #e0f8f8;
  13. }
  14. .ListLine1 {
  15. background: #f8b0f8;
  16. }

OK,今天Ruby on Rails列表頁面的優(yōu)化內(nèi)容就介紹到這里。


網(wǎng)頁名稱:RubyonRails列表頁面如何進(jìn)行優(yōu)化
當(dāng)前路徑:http://www.5511xx.com/article/cdhshsd.html