Class: Eventable::OpeningPeriodsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  if @opening_period.update_attributes(params[:eventable_opening_period])
    try_after_callback do
      flash[:notice] = 'Opening Period was successfully added.'
      redirect_to (if params[:list]
                     eventable_event_opening_periodlist_path @event
                   else
                     eventable_event_opening_period_path @event, @opening_period
                   end)
    end
  else
    try_after_callback :fail do
      render :action => "new"
    end
  end
end

#destroyObject



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

def destroy
  @opening_period.destroy
  try_after_callback do
    redirect_to (if params[:list]
                   eventable_event_opening_periodlist_path @event
                 else
                   eventable_event_opening_periods_path @event
                 end)
  end
end

#updateObject



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

def update
  if @opening_period.update_attributes(params[:eventable_opening_period])
    try_after_callback do
      flash[:notice] = 'Opening period was successfully updated.'
      redirect_to (if params[:list]
                     eventable_event_opening_periodlist_path @event
                   else
                     eventable_event_opening_period_path @event, @opening_period
                   end)
    end
  else
    try_after_callback :fail do
      render :action => "edit"
    end
  end
end