I have a Post model and Comment model (Post has_many comments, Comment belongs_to Post)
I want to validate a field in my Comment model where they can only create/update if a comment field is less than the difference between 2 Post date_fields. How do I go about achieving this?
Right now, in my Comment model, I have:
validates :comment_check, presence: true, :numericality => { :greater_than_or_equal_to => 0 }
I just need to add the validation to make it :less_than_or_equal_to the Post date diff. I also have this model method in my Post model:
def self.days_diff
(end_date.to_date - start_date.to_date).to_i
end
Any help would be greatly appreciated!