Class: Spud::Admin::CalendarsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Spud::Admin::CalendarsController
- Defined in:
- app/controllers/spud/admin/calendars_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/spud/admin/calendars_controller.rb', line 16 def create @calendar = SpudCalendar.new(params[:spud_calendar]) if @calendar.save redirect_to spud_admin_list_spud_calendar_events_path else render :action => "new" end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/spud/admin/calendars_controller.rb', line 41 def destroy @calendar = SpudCalendar.find(params[:id]) @calendar.spud_calendar_events.each do |event| event.update_attribute(:spud_calendar_id, 0) end @calendar.destroy respond_with(@calendar) do |format| format.js { render(:nothing => true) } end end |
#edit ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/spud/admin/calendars_controller.rb', line 25 def edit @page_name = "Edit Calendar" @calendar = SpudCalendar.find(params[:id]) respond_with(@calendar) end |
#new ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/spud/admin/calendars_controller.rb', line 10 def new @page_name = "New Calendar" @calendar = SpudCalendar.new respond_with(@calendar) end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/spud/admin/calendars_controller.rb', line 31 def update @calendar = SpudCalendar.find(params[:id]) if @calendar.update_attributes(params[:spud_calendar]) flash[:notice] = 'Calendar was successfully updated.' redirect_to spud_admin_list_spud_calendar_events_path else render :action => "edit" end end |