How to make a custom multi-part field for an integer in Rails 3?
I want to have 开发者_开发技巧a field for a span of time in a rails form, with 3 input fields, for hours, minutes, and seconds, and store all of this as in integer (in seconds) in the DB. How would I go about accomplishing this?
I don't think this can be done automatically, but some simple controller code would work.
params[:timespan] = (params.delete(:hours).to_i * 3600) +
(params.delete(:minutes).to_i * 60) +
params.delete(:seconds).to_i
精彩评论