Class: BookingsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bookings_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#authorize_customer!, #authorize_provider!

Instance Method Details

- (Object) create



19
20
21
22
23
24
25
26
27
# File 'app/controllers/bookings_controller.rb', line 19

def create
  @booking = new_booking(booking_params)

  if @booking.save
    redirect_to root_path, success: 'Booking created with success.'
  else
    render 'new'
  end
end

- (Object) destroy



43
44
45
46
47
# File 'app/controllers/bookings_controller.rb', line 43

def destroy
  current_user.bookings.find(params[:id]).destroy!

  redirect_to root_path, success: 'Booking deleted successfully.'
end

- (Object) edit



29
30
31
# File 'app/controllers/bookings_controller.rb', line 29

def edit
  @booking = current_user.bookings.find(params[:id])
end

- (Object) index



5
6
7
8
9
10
11
12
13
# File 'app/controllers/bookings_controller.rb', line 5

def index
  @calendar_form = CalendarForm.new request, calendar_form_params
  @provider_chooser_form = ProviderChooserForm.new(provider_chooser_form_params)
  @slots = @provider_chooser_form.week_slots(@calendar_form.current_week)

  if @provider_chooser_form.providers.empty?
    redirect_to root_path, notice: "You are not affiliated with any provider yet."
  end
end

- (Object) new



15
16
17
# File 'app/controllers/bookings_controller.rb', line 15

def new
  @booking = new_booking
end

- (Object) update



33
34
35
36
37
38
39
40
41
# File 'app/controllers/bookings_controller.rb', line 33

def update
  @booking = current_user.bookings.find(params[:id])

  if @booking.update booking_params
    redirect_to root_path, success: 'Booking updated with success.'
  else
    render 'new'
  end
end