Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Log < ActiveRecord::Base
- def self.calculate_time(log)
- @result = Time.at(log.updated_at - log.created_at).gmtime.strftime('%R:%S')
- end
- def self.calculate_all_time(username)
- @log = Log.find_all_by_username(username)
- seconds = 0
- @log.each do |f|
- seconds += (f.updated_at - f.created_at)
- end
- Time.at(seconds).gmtime.strftime('%R:%S')
- end
- end
Add Comment
Please, Sign In to add comment