Closed atflick closed 7 years ago
Yeah, start_time
will just be 'expecting' a DateTime
object. You can create a DateTime
object passing whatever parameters you need. This is kind of an adapter-based solution.
You might be able to pass a Date
object and a Time
object as arguments to DateTime.new
, also.
Andy helped me, I created a method in my model that combines the date and time and puts it in the column I need and just needed to update my controller as follows
def create
@reservation = Reservation.new(reservation_params)
@reservation.combine_datetime
@reservation.save
redirect_to reservations_path
end
I haven't been able to find a good answer or if this is even possible. But right now I am using this calendar gem that uses a 'datetime' data type to display the events on the calendar, labeled 'start_time' in the snippet of my model below. For controlling incoming data types and better UX I have split out the time and date columns. Basically I am trying to figure out if it's possible to populate the 'start_time' field with a combination of the two. I have a method for this but just not quite sure how to correctly implement it or if it's even possible?
Thanks! -Andy