Class: Gaku::ContactsController
- Inherits:
-
GakuController
- Object
- CoreController
- GakuController
- Gaku::ContactsController
- Includes:
- PolymorphicResourceConcern
- Defined in:
- app/controllers/gaku/contacts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #make_primary ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods inherited from GakuController
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/controllers/gaku/contacts_controller.rb', line 24 def create creator = ContactCreation.new(contact_params.merge(contactable: @polymorphic_resource)) creator.save @contact = creator.contact set_count respond_with @contact end |
#destroy ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/controllers/gaku/contacts_controller.rb', line 40 def destroy if @contact.destroy @polymorphic_resource.contacts.first.try(:make_primary) if @contact.primary? end set_count respond_with @contact end |
#edit ⇒ Object
32 33 |
# File 'app/controllers/gaku/contacts_controller.rb', line 32 def edit end |
#index ⇒ Object
14 15 16 17 |
# File 'app/controllers/gaku/contacts_controller.rb', line 14 def index @contacts = @polymorphic_resource.contacts respond_with @contacts end |
#make_primary ⇒ Object
48 49 50 51 |
# File 'app/controllers/gaku/contacts_controller.rb', line 48 def make_primary @contact.make_primary respond_with @contact end |
#new ⇒ Object
19 20 21 22 |
# File 'app/controllers/gaku/contacts_controller.rb', line 19 def new @contact = Contact.new respond_with @contact end |
#update ⇒ Object
35 36 37 38 |
# File 'app/controllers/gaku/contacts_controller.rb', line 35 def update ContactUpdation.new(@contact).update(contact_params) respond_with @contact end |