Class: EventsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/app/controllers/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
# File 'lib/app/controllers/events_controller.rb', line 21

def create
  @event = @calendar.events.create(params[:event])
  flash[:notice] = "Event successfully created" if @event.save
  respond_with(@calendar, @event)
end

#destroyObject



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

def destroy
  @event = @calendar.events.find(params[:id])
  @event.destroy

  respond_to do |format|
    format.html { redirect_to(calendars_events_url(@calendar, @event)) }
    format.xml  { head :ok }
  end
end

#editObject



17
18
19
# File 'lib/app/controllers/events_controller.rb', line 17

def edit
  respond_with(@calendar, (@event = @calendar.events.find(params[:id])))
end

#indexObject



5
6
7
# File 'lib/app/controllers/events_controller.rb', line 5

def index
  respond_with(@calendar, (@events = @calendar.events.all))
end

#newObject



13
14
15
# File 'lib/app/controllers/events_controller.rb', line 13

def new
  respond_with(@calendar, (@event = @calendar.events.new))
end

#showObject



9
10
11
# File 'lib/app/controllers/events_controller.rb', line 9

def show
  respond_with(@calendar, (@event = @calendar.events.find(params[:id])))
end

#updateObject



27
28
29
30
31
# File 'lib/app/controllers/events_controller.rb', line 27

def update
  @event = @calendar.events.find(params[:id])
  @event.update_attributes(params[:calendar])
  respond_with(@calendar, @event)
end