title: time_select blank field saves a default time when form is submitted
body: <p>Im having trouble understanding my options for time_select. My goal is to have only user created time selections render in my show action after form submission. </p>
  
  <p>What is happening however is a default time of 12:00 AM being rendered for all time_select fields not touched by a user. I am looking for a way to either stop default time values from saving (which if I had to guess, isn't possible), or create a conditional that would allow me to prevent default time values from rendering.</p>
  
  <p>I have looked over the following with no success so far:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/559584/nil-value-on-datetime-select">Nil value on datetime_select?</a></li>
  <li><a href="https://stackoverflow.com/questions/10851659/optional-time-select-with-allow-blank-defaults-to-0000">Optional time_select with allow_blank defaults to 00:00</a></li>
  <li><a href="https://stackoverflow.com/questions/8695745/rails-time-select-set-default">Rails time_select set default</a></li>
  <li><a href="https://stackoverflow.com/questions/9514520/rails-3-how-to-prevent-my-validations-to-pass-a-nil-time-from-time-select-dro">Rails 3: How to prevent my validations to pass a &quot;nil time&quot; from time_select dropdowns?</a></li>
  <li><a href="http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_select" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_select</a></li>
  </ol>
  
  <p>Here is my code: </p>
  
  <pre><code>_form.html.erb (only the snippet that I am having trouble with for brevity)
  
  
                      &lt;td&gt;
                      &lt;span style="display: block; width: auto; margin-left: 4%"&gt;
                          &lt;%= f.time_select :med1_time_of_day1, { include_blank: true, twelve_hour: true, minute_step: 15, ampm: true }, style: "width: 45%;" %&gt;
                      &lt;/span&gt;
                      &lt;span style="display: block; width: auto; margin-left: 4%"&gt;
                          &lt;%= f.time_select :med1_time_of_day2, { include_blank: true, twelve_hour: true, minute_step: 15, ampm: true }, style: "width: 45%;" %&gt;
                      &lt;/span&gt;
                      &lt;span style="display: block; width: auto; margin-left: 4%"&gt;
                          &lt;%= f.time_select :med1_time_of_day3, { include_blank: true, twelve_hour: true, minute_step: 15, ampm: true }, style: "width: 45%;" %&gt;
                      &lt;/span&gt;
                      &lt;span style="display: block; width: auto; margin-left: 4%"&gt;
                          &lt;%= f.time_select :med1_time_of_day4, { include_blank: true, twelve_hour: true, minute_step: 15, ampm: true }, style: "width: 45%;" %&gt;
                      &lt;/span&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>show.html.erb
  
  &lt;table class="table table-bordered table-striped"&gt;
          &lt;thead&gt;
              &lt;th&gt;Medication Name &amp; Instructions for Use&lt;/th&gt;
              &lt;th&gt;Time of Day&lt;/th&gt;
              &lt;th&gt;
                  Day(s) of the Month Medication was Taken
              &lt;/th&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;td&gt;
                  &lt;%= @med_record_form.med1_name %&gt;
                  &lt;%= @med_record_form.med1_instruct %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;% unless @med_record_form.med1_time_of_day1.nil? %&gt;
                      &lt;%= @med_record_form.med1_time_of_day1.strftime("%I:%M %p") %&gt;
                      &lt;br /&gt;
                  &lt;% end %&gt;
                  &lt;% unless @med_record_form.med1_time_of_day2.nil? %&gt;
                      &lt;%= @med_record_form.med1_time_of_day2.strftime("%I:%M %p") %&gt;
                      &lt;br /&gt;
                  &lt;% end %&gt;
                  &lt;% unless @med_record_form.med1_time_of_day3.nil? %&gt;
                      &lt;%= @med_record_form.med1_time_of_day3.strftime("%I:%M %p") %&gt;
                      &lt;br/&gt;
                  &lt;% end %&gt;
                  &lt;% unless @med_record_form.med1_time_of_day4.nil? %&gt;
                      &lt;%= @med_record_form.med1_time_of_day4.strftime("%I:%M %p") %&gt;
                      &lt;br /&gt;
                  &lt;% end %&gt;
              &lt;/td&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <blockquote>
    <p>Note: I've also tried replacing @instance_var.nil? with 
    @instance_var.blank? and  @instance_var.empty? without success.</p>
  </blockquote>
  
  <hr>
  
  <p>And just in case the controller is needed...</p>
  
  <pre><code>    med_record_forms_controller.rb
  
      class MedRecordFormsController &lt; ApplicationController
    before_filter :get_resident
  
    def index
      @med_record_form = @resident.med_record_forms
    end
  
    def new
      @med_record_form = @resident.med_record_forms.build
    end
  
    def create
      @med_record_form = @resident.med_record_forms.build(params[:med_record_form])
      if @med_record_form.save
        redirect_to [@resident, @med_record_form] #, flash_class[:success] = "Form was created!"
      else
        render 'new' #, flash[:error] = "There was a problem with the form"
      end
    end
  
    def show
      @med_record_form = @resident.med_record_forms.find(params[:id])
    end
  
    def update
      @med_record_form = @resident.med_record_forms.find(params[:id])
      if @med_record_form.update_attributes(params[:med_record_form])
        flash[:success] = "Form updated"
        redirect_to controller: 'residents', action: 'show', id: params[:id]
      else
        render 'edit', flash[:error] = "Unable to update form"
      end
    end
  
    def edit
      @med_record_form = @resident.med_record_forms.find(params[:id])
    end
  
    def destroy
      @med_record_form = @resident.med_record_forms.find(params[:id])
      @med_record_form.destroy
      flash[:notice] = "You sure?"
      redirect_to resident_med_record_forms_path
    end
  
    private
    # get_resident converts the resident_id given by the routing
    # into an @resident object, for use in this controller &amp; coresponding views
    def get_resident
      @resident = Resident.find(params[:resident_id])
    end
  end
  </code></pre>