Created
April 29, 2010 03:14
-
-
Save achiurizo/383069 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
Admin.controllers :accounts do | |
get :index do | |
@accounts = Account.all | |
render 'accounts/index' | |
end | |
get :new do | |
@account = Account.new | |
render 'accounts/new' | |
end | |
post :create do | |
@account = Account.new(params[:account]) | |
if (@account.save rescue false) | |
flash[:notice] = 'Account was successfully created.' | |
redirect url(:accounts, :edit, :id => @account.id) | |
else | |
render 'accounts/new' | |
end | |
end | |
get :edit, :with => :id do | |
@account = Account.filter(:id => params[:id]).first | |
render 'accounts/edit' | |
end | |
put :update, :with => :id do | |
@account = Account.filter(:id =>params[:id]).first | |
if (@account.update(params[:account]) rescue false) | |
flash[:notice] = 'Account was successfully updated.' | |
redirect url(:accounts, :edit, :id => @account.id) | |
else | |
render 'accounts/edit' | |
end | |
end | |
delete :destroy, :with => :id do | |
account = Account.filter(:id => params[:id]).first | |
if account != current_account && account.destroy | |
flash[:notice] = 'Account was successfully destroyed.' | |
else | |
flash[:error] = 'Impossible destroy Account!' | |
end | |
redirect url(:accounts, :index) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment