Module: TinyCore::Controllers::AdminAccounts

Defined in:
lib/tiny_core/controllers/admin_accounts.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



4
5
6
7
8
# File 'lib/tiny_core/controllers/admin_accounts.rb', line 4

def self.included(receiver)
  receiver.before_filter :login_required
  receiver.before_filter :can_see_all_accounts!
  receiver.before_filter :can_edit_all_accounts!, :only => [ :edit, :update ]
end

Instance Method Details

#editObject



22
23
24
# File 'lib/tiny_core/controllers/admin_accounts.rb', line 22

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

#indexObject



10
11
12
13
14
15
16
# File 'lib/tiny_core/controllers/admin_accounts.rb', line 10

def index
  @search_filter = SearchFilter.new(params[:search_filter])
  @accounts = Account.paginate_for_list(@search_filter, :page => params[:page])
  render :update do |page|
    page.replace_html 'accounts', :partial => 'index'
  end if request.xhr?
end

#showObject



18
19
20
# File 'lib/tiny_core/controllers/admin_accounts.rb', line 18

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

#updateObject



26
27
28
29
30
31
32
33
34
# File 'lib/tiny_core/controllers/admin_accounts.rb', line 26

def update
  @account = Account.find(params[:id])
  if @account.update_attributes_without_attr_protected(params[:account])
    flash[:notice] = I18n.t("flash.notice.updated_account", :account => @account.name)
    redirect_to admin_accounts_path
  else
    render :action => 'edit'
  end
end