custom_form.html.erb
<%= f.date_select :creation_date %>
I have a column creation_date
in my database with date
type. Everything works fine, but I need to validate :creation_date
in my server.rb model.
I need to validate:
- Date type to be valid
- Max\min date start\end period
Simple :creation_date
validation validates_date :creation_date, presence =>true ...
calling Undefined Method
error.
I read on a forum that if date is not valid, then my :creation_date
will be set to nil
.
I guess we can check :creation_date
for nil
value to deal with 1 item in the list?
And how can I implement second item?
UPD (Resolved):
Problem was in neasted model. I tried to validate attribute of my user model in server.rb. I moved validation to user.rb and now i'm able to validate :creation_date
with timeliness gem
Try this: