i am using before validate to format my input from my view file for the columns of type DateTime. I have pasted the code for the validation and works well for creating a new record. However, when trying to update the record where the columns from and to (of type DateTime) are null, then they are not set in the update call. It seems like i am checking to see if the attribute is present and then does not find one (i guess it looks in the prior saved values in the db which is indeed empty?) even though on is sent in the update request.
before_validation do self.from = Time.parse(from.to_s) if attribute_present?("from") self.to = Time.parse(to.to_s) if attribute_present?("to") #puts "hello" end