title: Rails 4 Do not work flash[:notice] and render
body: <p>I have been searching the solution whole day today, but unable to find out. 
  This is a simple appointment system. 
  I try to show the error message and render to 'new' when the user submit invalid date/time(eg: Sat, Sun / not range between 09:00-17:00). I keep getting the error "First argument in form cannot contain nil or be empty" when the condition is falling into the validation. 
  Also, when its not in invalid condition, the flash message is not appearing, but redirect to the desired page. </p>
  
  <p>In _form.html.erb </p>
  
  <pre><code>&lt;%= form_for @appointment do |f| %&gt;
    &lt;%= f.date_field :appointment_date, :min =&gt; Date.today %&gt;
    &lt;%= time_field_tag 'appointment[appointment_time]' %&gt;
    &lt;%= f.submit "Submit"%&gt;
  &lt;% end %&gt; 
  </code></pre>
  
  <p>In Appointment controller (class AppointmentsController &lt; ApplicationController)</p>
  
  <pre><code>def create
    appointment = Appointment.new appointment_params
    date = params[:appointment][:appointment_date] + ' ' + params[:appointment][:appointment_time]
    appointment.appointment_date = date
    check = DateTime.parse(appointment.appointment_date.to_s)
      if check.wday == 6 || check.wday == 7
         flash[:notice] = "Please chose Mon-Fri."
         render :new
      elsif check.hour &gt; 9 || check.hour &lt; 17
         flash[:notice] = "Please chose the range between 09:00-17:00."
         render :new
      elsif
        appointment.save
        flash[:notice]= "Appointment is saved."
        redirect_to appointment
      else
        render :new
      end
   end
  </code></pre>
  
  <p>flash[:notice] do not appear in any condition. 
  render :new does not work and give the error as  "First argument in form cannot contain nil or be empty"</p>
  
  <p>Thanks in advance. </p>