Skip to content

Instantly share code, notes, and snippets.

@aj07
Created June 7, 2016 09:05
Show Gist options
  • Save aj07/54db84129929577fde58f23c2c282441 to your computer and use it in GitHub Desktop.
Save aj07/54db84129929577fde58f23c2c282441 to your computer and use it in GitHub Desktop.
<div class="form-group">
<%= f.label :from_date, "From Date", :class => 'control-label col-md-2' %>
<div class="col-md-10">
<%= f.text_field :from_date, :class => 'form-control date', :placeholder => "Start Date", :value => "#{ f.object.from_date.nil? ? " " : f.object.from_date.now.strftime("%m/%d/%Y")}" %>
</div>
@arvindvyas
Copy link

arvindvyas commented Jun 7, 2016


      def expiration_date_cannot_be_in_the_past
        if expiration_date.present? && expiration_date < Date.today
          errors.add(:expiration_date, "can't be in the past")
        end
      end  

Here expiration_date is the date field , so check with debugger weather you are getting date on it or not if you are getting that then check this condition, it should work but how you have implemented it is looking like you are checking wrong attribute. As I can see you don't have date field with the name of expiration_date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment