ruby"2.5.1" Rails"5.2.4.3"
As the price increases, it becomes difficult to understand the amount, so we will implement digit separators for the product prices on the following three pages. This time we will use a helper method called delimited.
--Top page screen before modification
--Product detail page screen before modification
--Product purchase page screen before modification
(* For product details / purchase page)
products_helper.rb
module ProductsHelper
def converting_to_jpy(price)
"#{price.to_s(:delimited, delimiter: ',')}Circle"
end
end
(* For top page)
tops_helper.rb
module TopsHelper
def converting_to_jpy_top(price)
"#{price.to_s(:delimited, delimiter: ',')}"
end
end
ruby:show.html.haml
.show__main__product__content__information__price
%span
= converting_to_jpy(@product.price)
ruby:purchase.html.haml
%p.purchase__main__product-info__inner__content__detail__price
%span
= converting_to_jpy(@product.price)
ruby:_item-preview.html.haml
.item__caption__details__price
= converting_to_jpy_top(product.price)
converting_to_jpy_top
to separate it from the product.This completes the changes on each page.
--Corrected top page
--Corrected product detail page
--Revised product purchase page
With the introduction of digit grouping, I wondered if the page was a little tighter.
that's all.
Recommended Posts