Than you so much for your reply and your help! I'm still a little 
confused however as I'm still getting an error:

syntax error, unexpected end-of-input, expecting keyword_end

I don't know why it's complaining about end keywords. As far as I can 
tell they are ok.


I don't understand what you mean when you say:
"# @appointments has not been loaded, is nil, you will get an error
here
    # you can add a before_action filter and load it there
    @appointments.find(params[:date, :timeslot]) # dont load this here
since is not always needed"

Isn't the @appointments.find(params[:date, :timeslot]) not instanciated 
in the index method above?

Do you mean to put a before_action filter in the appointments 
controller?


appointments controller:

def create
    @appointment = Appointment.new(appointment_params)

      respond_to do |format|
      unless @appointments.isValid?



        if @appointment.save
          format.html { redirect_to @appointment, notice: 'Appointment 
was successfully created.' }
          format.json { render :show, status: :created, location: 
@appointment }
        elsif
          format.html { render :new }
          format.json { render json: @appointment.errors, status: 
:unprocessable_entity }
        else
          redirect_to root_path
        end
    end
  end


appointments Model:

class Appointment < ActiveRecord::Base

        def isValid?
        date.present? && timeslot.present?
    end
end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/690b189b71c3f828d7959f10659683fb%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to