![](/img/trans.png)
[英]Replacing time_ago_in_words with timeago jQuery plugin in i18n-ized Rails 3.2 app
[英]how do I use rails time_ago_in_words in backbone template
有沒有辦法使用hamlc在主干模板中使用rails標准方法(例如time_ago_in_words)? 當我嘗試這個
.created_at= time_ago_in_words e.created_at
引發異常
Uncaught ReferenceError: time_ago_in_words is not defined
I had to create this simple method and return to the template.
include ActionView::Helpers::DateHelper
def personalize_time(c)
coll = []
c.each do |v|
coll << {"created_at" => time_ago_in_words(v['created_at']), "collection" => v}
end
coll
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.