我在任何地方都看着,但似乎无法找到一个好的解决办法。
My form has a date (textfield with datepicker) and a time (textfield with timepicker), which I want to map to an model field called due_at
.
迄今为止,我一直在我的控制人员中处理这一模式,有不同的参数,可以参加,直到有一天,才能人工确定模式,但是,它令人感到迷惑,而且确实认为这一逻辑应当保留在模型/概览中。
I would like to be able to handle the two form fields to an attribute in the model, then split it back out for errors, edit action etc. Basically a custom way of performing what the standard datetime_select does, but putting my own touch to it.
Is there something that I can put in my model like ?
def due_at=(date, time)
...
end
I been looking a number of places, but can t find out how you would do this. People say to use javascript to populate a hidden field, but just don t seem like the cleanest solution for a pretty simple problem.
Any advice/help would be much appreciated.
Thanks.