Last change
on this file since 0f6d75f was 7b7d827, checked in by njw <njw@…>, 11 years ago |
opened projects: hothotwrite and contact
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[7b7d827] | 1 | class AdmincontactController < ApplicationController
|
---|
| 2 | layout 'standard'
|
---|
| 3 |
|
---|
| 4 | # logged_in
|
---|
| 5 | before_filter :authorize
|
---|
| 6 |
|
---|
| 7 | def index
|
---|
| 8 | list
|
---|
| 9 | render :action => 'list'
|
---|
| 10 | end
|
---|
| 11 |
|
---|
| 12 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
---|
| 13 | verify :method => :post, :only => [ :destroy, :create, :update ],
|
---|
| 14 | :redirect_to => { :action => :list }
|
---|
| 15 |
|
---|
| 16 | def list
|
---|
| 17 | @contacts = Contact.find(:all)
|
---|
| 18 | end
|
---|
| 19 |
|
---|
| 20 | def show
|
---|
| 21 | @contact = Contact.find(params[:id])
|
---|
| 22 | end
|
---|
| 23 |
|
---|
| 24 | def new
|
---|
| 25 | @contact = Contact.new
|
---|
| 26 | end
|
---|
| 27 |
|
---|
| 28 | def create
|
---|
| 29 | @contact = Contact.new(params[:contact])
|
---|
| 30 | if @contact.save
|
---|
| 31 | flash[:notice] = 'Contact was successfully created.'
|
---|
| 32 | redirect_to :action => 'list'
|
---|
| 33 | else
|
---|
| 34 | render :action => 'new'
|
---|
| 35 | end
|
---|
| 36 | end
|
---|
| 37 |
|
---|
| 38 | def edit
|
---|
| 39 | @contact = Contact.find(params[:id])
|
---|
| 40 | end
|
---|
| 41 |
|
---|
| 42 | def update
|
---|
| 43 | @contact = Contact.find(params[:id])
|
---|
| 44 | if @contact.update_attributes(params[:contact])
|
---|
| 45 | flash[:notice] = 'Contact was successfully updated.'
|
---|
| 46 | redirect_to :action => 'show', :id => @contact
|
---|
| 47 | else
|
---|
| 48 | render :action => 'edit'
|
---|
| 49 | end
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | def destroy
|
---|
| 53 | Contact.find(params[:id]).destroy
|
---|
| 54 | redirect_to :action => 'list'
|
---|
| 55 | end
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.