search for: duration_in_seconds

Displaying 2 results from an estimated 2 matches for "duration_in_seconds".

2012 Jan 27
2
to_json performance
...ttle sorcery we can transform each Array representing the requested record values in a Hash with keys mapped, like so: class Hash def self.transpose(keys, values) self[*keys.zip(values).flatten] end end keys = %W{token artist album genre release_year title duration duration_in_seconds position play_count favorited disc_number} my_hash = @playlist.media_files.ordered.values_of(*keys).collect{ | v| Hash.transpose(keys, v) } Nice, now we have a Array of Hash without instantiating AR objects but with all the info we need about our objects. This operation proved to be _extremely...
2006 Mar 18
1
rails-y way to handle quasi-numeric type
I have a class called Duration that represents a unit of time. It has lots of time-related methods and an attribute that represents the duration in seconds. I want to store it in my db. I had a column type of NUMERIC, so if i save it, rails trys to coerce it to a float automagically and fails. I need to display it and store it as a number but treat it in the middle layer as a Duration so I can