Class: Rails::Contact::ContactsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Rails::Contact::ContactsController
- Defined in:
- app/controllers/rails/contact/contacts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 20 def create @contact = Contact.new(contact_params) if @contact.save enqueue_index(@contact.id) redirect_to contact_path(@contact), notice: "Contact created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
39 40 41 42 43 44 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 39 def destroy id = @contact.id @contact.destroy! IndexContactJob.perform_later(id, remove: true) redirect_to contacts_path, notice: "Contact deleted." end |
#edit ⇒ Object
18 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 18 def edit; end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 6 def index @query = params[:q].to_s.strip @contacts = Search::Query.new(@query, filters: filter_params).call end |
#new ⇒ Object
13 14 15 16 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 13 def new @contact = Contact.new build_default_associations end |
#show ⇒ Object
11 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 11 def show; end |
#update ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/rails/contact/contacts_controller.rb', line 30 def update if @contact.update(contact_params) enqueue_index(@contact.id) redirect_to contact_path(@contact), notice: "Contact updated." else render :edit, status: :unprocessable_entity end end |