I have been looking everywhere but can't seem to find a good solution for this.
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
.
So far I been handling it in my controller with separate parameters to join it up to a datetime then set the model field manually, but it's messy and really think this logic should be kept in model/view.
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.