有没有办法在主干模板中使用rails标准方法,例如time_ago_in_words,也使用hamlc?我试过这个时
.created_at= time_ago_in_words e.created_at
抛出异常
Uncaught ReferenceError: time_ago_in_words is not defined
答案 0 :(得分:0)
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