开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜