簡體   English   中英

如何在主干模板中使用rails time_ago_in_words

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM