Class: Eventable::OpeningTimesController

Inherits:
EventableController show all
Defined in:
app/controllers/eventable/opening_times_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/eventable/opening_times_controller.rb', line 10

def create
  if @opening_time.update_attributes(params[:eventable_opening_time])
    try_after_callback do
      flash[:notice] = 'Opening time was successfully added.'
      redirect_to (if params[:list]
                     eventable_opening_period_opening_timelist_path @opening_period
                   else
                     eventable_opening_period_opening_time_path @opening_period, @opening_time
                   end)
    end
  else
    try_after_callback :fail do
      render :action => "new"
    end
  end
end

#destroyObject



44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/eventable/opening_times_controller.rb', line 44

def destroy
  @opening_time.destroy
  try_after_callback do
    redirect_to (if params[:list]
                   eventable_opening_period_opening_timelist_path @opening_period
                 else
                   eventable_opening_period_opening_times_path @opening_period
                 end)
  end
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/eventable/opening_times_controller.rb', line 27

def update
  if @opening_time.update_attributes(params[:eventable_opening_time])
    try_after_callback do
      flash[:notice] = 'Opening time was successfully updated.'
      redirect_to (if params[:list]
                     eventable_opening_period_opening_timelist_path @opening_period
                   else
                     eventable_opening_period_opening_time_path @opening_period, @opening_time
                   end)
    end
  else
    try_after_callback :fail do
      render :action => "edit"
    end
  end
end