Class: AccountsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AccountsController
- Defined in:
- app/controllers/accounts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /accounts POST /accounts.xml.
-
#destroy ⇒ Object
DELETE /accounts/1 DELETE /accounts/1.xml.
-
#edit ⇒ Object
GET /accounts/1/edit.
-
#index ⇒ Object
GET /accounts GET /accounts.xml.
- #move_down ⇒ Object
- #move_up ⇒ Object
-
#new ⇒ Object
GET /accounts/new GET /accounts/new.xml.
-
#show ⇒ Object
GET /accounts/1 GET /accounts/1.xml.
-
#update ⇒ Object
PUT /accounts/1 PUT /accounts/1.xml.
Instance Method Details
#create ⇒ Object
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 = 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 |
#destroy ⇒ Object
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 = Account.find(params[:id]) @account.destroy respond_to do |format| format.html { redirect_to(accounts_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /accounts/1/edit
36 37 38 |
# File 'app/controllers/accounts_controller.rb', line 36 def edit @account = Account.find(params[:id]) end |
#index ⇒ Object
GET /accounts GET /accounts.xml
4 5 6 7 8 9 10 11 |
# File 'app/controllers/accounts_controller.rb', line 4 def index @accounts = Account.all(:order => "position") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @accounts } end end |
#move_down ⇒ Object
93 94 95 96 97 98 |
# File 'app/controllers/accounts_controller.rb', line 93 def move_down @account = Account.find(params[:id]) @account.move_lower redirect_to :back end |
#move_up ⇒ Object
86 87 88 89 90 91 |
# File 'app/controllers/accounts_controller.rb', line 86 def move_up @account = Account.find(params[:id]) @account.move_higher redirect_to :back end |
#new ⇒ Object
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 = Account.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @account } end end |
#show ⇒ Object
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 = Account.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @account } end end |
#update ⇒ Object
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 = 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 |