Class: Admin::Campuses::ContactsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Campuses::ContactsController
- Defined in:
- app/controllers/gaku/admin/campuses/contacts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #make_primary ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 15 def create creator = ContactCreation.new(contact_params.merge(contactable: @campus)) creator.save @contact = creator.contact set_count respond_with @contact end |
#destroy ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 33 def destroy if @contact.destroy @campus.contacts.first.try(:make_primary) if @contact.primary? end set_count respond_with @contact end |
#edit ⇒ Object
23 24 25 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 23 def edit respond_with @contact end |
#make_primary ⇒ Object
41 42 43 44 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 41 def make_primary @contact.make_primary respond_with @contact end |
#new ⇒ Object
10 11 12 13 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 10 def new @contact = Contact.new respond_with @contact end |
#update ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/gaku/admin/campuses/contacts_controller.rb', line 27 def update ContactUpdation.new(@contact).update(contact_params) @contact.update(contact_params) respond_with @contact end |