문제

RAILS 도우미를 사용자 정의하는 가장 좋은 해결책이 무엇인지 궁금해하고있었습니다 : 와 같은 일을 할 수 있습니다.

    <span class="one">4</span>
    <span class="two">hours</span>
    <span class="three">ago</span>
.

또는 기본적으로 레이아웃이 어떻게 생겼는지?

감사합니다

도움이 되었습니까?

해결책

I would just create a helper that splits the result of time_ago_in_words on spaces and returns the array of words. Then you can format them however you want.

다른 팁

Instead of the method time_ago_in_words, you can use distance_of_time_in_words, which accepts locale in the option array: create a new locale where you can define "hours" with "hours", etc... and give it to distance_of_time_in_words. It should work, but I'm not sure how will be handled the HTML tags.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top