Class: AppointmentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/appointments/templates/appointments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/appointments/templates/appointments_controller.rb', line 20

def create
 @appointment = Appointment.create(params[:appointments])
  if @appointment.save
    redirect_to new_appointment_path
  else
    err = ''
    @appointment.errors.full_messages.each do |m|
    err << m
  end

    redirect_to new_appointment_path, :flash => { :alert => "#{err}, please try again" }
  end
end

#indexObject



3
4
5
6
7
8
9
# File 'lib/generators/appointments/templates/appointments_controller.rb', line 3

def index
  date_from_ajax = params[:matched_date]
  reduce = Appointment.where(:date => date_from_ajax)
  hour_on_date = reduce.collect {|x| x.hour}
  @new_dates = hour_on_date
  render :layout => false
end

#newObject



11
12
13
14
15
16
17
# File 'lib/generators/appointments/templates/appointments_controller.rb', line 11

def new
  @appointments = Appointment.create
 respond_to do |format|
   format.html
   format.js
   end
end