Created
October 28, 2009 13:06
-
-
Save mhfs/220476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContactsController < ApplicationController | |
def index | |
@contacts = current_user.contacts.paginate :page => params[:page] | |
end | |
def show | |
@contact = current_user.contacts.find(params[:id]) | |
end | |
def new | |
@contact = Contact.new | |
end | |
def create | |
@contact = current_user.contacts.build(params[:contact]) | |
if @contact.save | |
flash[:notice] = "Successfully created contact." | |
redirect_to @contact | |
else | |
render :action => 'new' | |
end | |
end | |
def edit | |
@contact = Contact.find(params[:id]) | |
end | |
def update | |
@contact = current_user.contacts.find(params[:id]) | |
if @contact.update_attributes(params[:contact]) | |
flash[:notice] = "Successfully updated contact." | |
redirect_to @contact | |
else | |
render :action => 'edit' | |
end | |
end | |
def destroy | |
@contact = current_user.contacts.find(params[:id]) | |
@contact.destroy | |
flash[:notice] = "Successfully destroyed contact." | |
redirect_to contacts_url | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment