0

有没有办法在骨干模板中使用 rails 标准方法,例如 time_ago_in_words 也使用 hamlc ?当我尝试这个

.created_at= time_ago_in_words e.created_at

它抛出一个异常

Uncaught ReferenceError: time_ago_in_words is not defined
4

1 回答 1

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
于 2015-10-30T19:33:32.250 回答