Class: AccountsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/accounts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /accounts POST /accounts.xml



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/accounts_controller.rb', line 42

def create
  @account = .new(params[:account])

  respond_to do |format|
    if @account.save
      flash[:notice] = 'Account was successfully created.'
      format.html { redirect_to(@account) }
      format.xml  { render :xml => @account, :status => :created, :location => @account }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @account.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /accounts/1 DELETE /accounts/1.xml



76
77
78
79
80
81
82
83
84
# File 'app/controllers/accounts_controller.rb', line 76

def destroy
  @account = .find(params[:id])
  @account.destroy

  respond_to do |format|
    format.html { redirect_to(accounts_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /accounts/1/edit



36
37
38
# File 'app/controllers/accounts_controller.rb', line 36

def edit
  @account = .find(params[:id])
end

#indexObject

GET /accounts GET /accounts.xml



4
5
6
7
8
9
10
11
# File 'app/controllers/accounts_controller.rb', line 4

def index
  @accounts = .all(:order => "position")

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

#move_downObject



93
94
95
96
97
98
# File 'app/controllers/accounts_controller.rb', line 93

def move_down
  @account = .find(params[:id])
  @account.move_lower

  redirect_to :back
end

#move_upObject



86
87
88
89
90
91
# File 'app/controllers/accounts_controller.rb', line 86

def move_up
  @account = .find(params[:id])
  @account.move_higher

  redirect_to :back
end

#newObject

GET /accounts/new GET /accounts/new.xml



26
27
28
29
30
31
32
33
# File 'app/controllers/accounts_controller.rb', line 26

def new
  @account = .new

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

#showObject

GET /accounts/1 GET /accounts/1.xml



15
16
17
18
19
20
21
22
# File 'app/controllers/accounts_controller.rb', line 15

def show
  @account = .find(params[:id])

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

#updateObject

PUT /accounts/1 PUT /accounts/1.xml



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/accounts_controller.rb', line 59

def update
  @account = .find(params[:id])

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