I’m trying to write a custom validation…people enter in a start and end time into a site and I’m trying to write a validation to check that the end comes after the start. I’ve tried to convert it to Unix time, but then I get a noMethodError. I would like to pass the symbols for the start time and end time into this method and then compare the two.
def validates_end_is_after_start(*attr_names)
start_hour = attr_names[0].to_i
end_hour = attr_names[1].to_i
The problem is that this ends up with a noMethodError for symbol. But that symbol points to a DateTime object (I think), how do I access that object? I think that there’s something I don’t understand about symbols in general.
You could use the
validatemethod which would have access to type-casted dates