Sha256: 92b25eec040ac9fb25aae8909f3973dc59ed360592cc23414aef23530da5fd30

Contents?: true

Size: 1.99 KB

Versions: 19

Compression:

Stored size: 1.99 KB

Contents

class ContactsController < ApplicationController
  # GET /contacts
  # GET /contacts.json
  def index
    @contacts = Contact.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render :json =>  @contacts }
    end
  end

  # GET /contacts/1
  # GET /contacts/1.json
  def show
    @contact = Contact.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render :json =>  @contact }
    end
  end

  # GET /contacts/new
  # GET /contacts/new.json
  def new
    @contact = Contact.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render :json =>  @contact }
    end
  end

  # GET /contacts/1/edit
  def edit
    @contact = Contact.find(params[:id])
  end

  # POST /contacts
  # POST /contacts.json
  def create
    @contact = Contact.new(params[:contact])

    respond_to do |format|
      if @contact.save
        format.html { redirect_to @contact, :notice => 'Contact was successfully created.' }
        format.json { render :json =>  @contact, :status => :created, :location => @contact }
      else
        format.html { render :action => "new" }
        format.json { render :json =>  @contact.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /contacts/1
  # PUT /contacts/1.json
  def update
    @contact = Contact.find(params[:id])

    respond_to do |format|
      if @contact.update_attributes(params[:contact])
        format.html { redirect_to @contact, :notice => 'Contact was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render :action => "edit" }
        format.json { render :json =>  @contact.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /contacts/1
  # DELETE /contacts/1.json
  def destroy
    @contact = Contact.find(params[:id])
    @contact.destroy

    respond_to do |format|
      format.html { redirect_to contacts_url }
      format.json { head :no_content }
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
active_list-6.5.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.5.0 test/dummy/app/controllers/contacts_controller.rb
active_list-6.4.2 test/dummy/app/controllers/contacts_controller.rb
active_list-6.4.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.4.0 test/dummy/app/controllers/contacts_controller.rb
active_list-6.3.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.3.0 test/dummy/app/controllers/contacts_controller.rb
active_list-6.2.4 test/dummy/app/controllers/contacts_controller.rb
active_list-6.2.3 test/dummy/app/controllers/contacts_controller.rb
active_list-6.2.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.2.0 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.5 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.4 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.3 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.2 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.1.0 test/dummy/app/controllers/contacts_controller.rb
active_list-6.0.1 test/dummy/app/controllers/contacts_controller.rb
active_list-6.0.0 test/dummy/app/controllers/contacts_controller.rb