Class: Manage::BusListsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Manage::BusListsController
- Defined in:
- app/controllers/manage/bus_lists_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #send_update_email ⇒ Object
- #show ⇒ Object
- #toggle_bus_captain ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 23 def create @bus_list = BusList.new(bus_list_params) @bus_list.save respond_with(:manage, @bus_list) end |
#destroy ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 34 def destroy School.where(bus_list_id: @bus_list.id).each do |school| school.questionnaires.where(riding_bus: true).map { |q| q.update_attribute(:riding_bus, false) } school.update_attribute(:bus_list_id, nil) end @bus_list.destroy respond_with(:manage, @bus_list) end |
#edit ⇒ Object
20 21 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 20 def edit end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 6 def index @bus_lists = BusList.all respond_with(:manage, @bus_lists) end |
#new ⇒ Object
15 16 17 18 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 15 def new @bus_list = BusList.new respond_with(:manage, @bus_list) end |
#send_update_email ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 53 def send_update_email @bus_list.passengers.each do |passenger| Mailer.delay.bus_list_update_email(passenger.id) end redirect_to [:manage, @bus_list] end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 11 def show respond_with(:manage, @bus_list) end |
#toggle_bus_captain ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 43 def toggle_bus_captain @questionnaire = Questionnaire.find(params[:questionnaire_id]) is_bus_captain = params[:bus_captain] == "1" @questionnaire.update_attribute(:is_bus_captain, is_bus_captain) if @questionnaire.reload.is_bus_captain Mailer.delay.bus_captain_confirmation_email(@bus_list.id, @questionnaire.user.id) end redirect_to [:manage, @bus_list] end |
#update ⇒ Object
29 30 31 32 |
# File 'app/controllers/manage/bus_lists_controller.rb', line 29 def update @bus_list.update_attributes(bus_list_params) respond_with(:manage, @bus_list) end |