Sha256: 47570053c5a62e7975be48e938bdc95b22dc3dd1957cf2428b82e45d003899fe
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 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
3 entries across 3 versions & 1 rubygems