홈페이지에 제품 목록을 표시해야하는 웹 응용 프로그램을 작성 중입니다.HAML을 사용하는보기에 도우미를 만드는 방법은 무엇입니까?
class ProductsController < ApplicationController
include ProductsHelper
def index
@products = Product.last(6).reverse
end
end
하고 해당보기 index.haml :이를 위해 은 내가 ProductsController가이
.main-container.col3-layout
.main
.col-wrapper
.col-main
.box.best-selling
%h3 Latest Products
%table{:border => "0", :cellspacing => "0"}
%tbody
- @products.each_slice(2) do |slice|
%tr
- slice.each do |product|
%td
%a{:href => product_path(:id => product.id)}
= product.title
%img.product-img{:alt => "", :src => product.image.path + product.image.filename, :width => "95"}/
.product-description
%p
%a{:href => "#"}
%p
See all from
%a{:href => category_path(:id => product.category.id)}
= product.category.label
=render "layouts/sidebar_left"
=render "layouts/sidebar_right"
내가 헬퍼를 사용하고 싶습니다이의 효율성을 개선하기 위해
,하지만 난 아무 생각이 없다 products_helper.rb 파일에 HAML 코드를 작성하지 않고 어떻게 할 수 있습니까?
어떻게해야합니까?
나는 못생긴다고 생각하지 않습니다. 부분품을 사용하지 않는 이유는 무엇입니까? –