Reputation: 325
Is there a way to use rails standard methods such as time_ago_in_words in backbone template also using hamlc ? When I tried this
.created_at= time_ago_in_words e.created_at
It throws an exception
Uncaught ReferenceError: time_ago_in_words is not defined
Upvotes: 0
Views: 126
Reputation: 325
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
Upvotes: 0