Sha256: ed06195dc83b5786c1eae1278b8a8662617ab5d466421a881844d9ee430ee6b1

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

# encoding: utf-8

module InvoiceBar
  class ContactsController < InvoiceBar::ApplicationController    
    inherit_resources
    respond_to :html, :json
    
    before_filter :require_login
    
    def index
      @contacts = current_user.contacts.page(params[:page])
      
      index! {}
    end

    def new
      @contact = Contact.new
      @contact.build_address

      new!
    end

    def create
      @contact = Contact.new(params[:contact])    
      current_user.contacts << @contact
      
      @contact.build_address unless @contact.address

      create! {}
    end
    
    def update
      update! {}
    end
    
    def destroy
      destroy! {}
    end
  
    protected
  
      def collection
        @contacts ||= end_of_association_chain.page(params[:page])
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
invoice_bar-0.0.6 app/controllers/invoice_bar/contacts_controller.rb
invoice_bar-0.0.5 app/controllers/invoice_bar/contacts_controller.rb