title: identifying conflicting appointments in rails works for update but not create?
body: <p>I wrote this conflict method to check if an appointment being saved or created dosent conflict with one thats already saved for a particular trainer. this method is called first thing after a person attempts to create or update existing appointments in the <code>def create</code> and <code>def update</code>. </p>
  
  <p>it works when updating the appointment but dosent identify the conflict when creating. </p>
  
  <p>any ideas? </p>
  
  <pre><code>  def is_conflicting()
      @new_appointment = person.appointments.build(params[:appointment])
      @appointments = Appointment.all(:conditions =&gt; { :date_of_appointment =&gt; @new_appointment.date_of_appointment, :doctor_id =&gt; @new_appointment.doctor_id})
      @appointments.each do |appointment|
        logger.info( appointment)
          if(@new_appointment.start_time &lt; appointment.end_time &amp;&amp; appointment.start_time &lt; @new_appointment.end_time)
            return true 
          end
      end
      return false
    end
  
  def create
      @appointment = person.appointments.build(params[:appointment])
        respond_to do |format|
          if(is_conflicting == false)
          if @appointment.save
  ....more code...
          end
          end
        end 
  end
  
    def update
      @appointment = person.appointments.find(params[:id])
        respond_to do |format|
          if(is_conflicting == false)
            if @appointment.update_attributes(params[:appointment])
          .....more code...........
             end
           end
       end
     end
  </code></pre>
  
  <p>the part of the form where doctor gets set.</p>
  
  <pre><code>  &lt;p&gt;
      &lt;%= f.label :doctor_id %&gt;
      &lt;%= f.select :doctor_id, Doctor.find(:all, :order =&gt; "name").collect { |s|
          [s.name, s.id]} %&gt;
    &lt;/p&gt;
  </code></pre>
  
  <p>thank you </p>