Class: ClerksController

Inherits:
AdminController show all
Defined in:
app/controllers/clerks_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#clean_search, #require_admin

Methods inherited from OfficeController

#error

Methods included from OfficeHelper

#best_euros, #current_basket, #current_basket_or_nil, #current_clerk, #date, #euros, #has_ssl?, #markdown, #new_basket, #paginate, #shipping_method

Instance Method Details

#createObject



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

def create
  @clerk = Clerk.create(params_for_model)
  if @clerk.save
    flash.notice = t(:create_success, :model => "clerk") 
    redirect_to clerk_path(@clerk)
  else
    render :edit
  end
end

#editObject



23
24
# File 'app/controllers/clerks_controller.rb', line 23

def edit
end

#indexObject

Uncomment for check abilities with CanCan authorize_resource



9
10
11
12
13
# File 'app/controllers/clerks_controller.rb', line 9

def index
  @q = Clerk.search params[:q]
  @clerk_scope = @q.result(:distinct => true)
  @clerks = @clerk_scope.paginate( :page => params[:page],:per_page => 20)
end

#newObject



18
19
20
21
# File 'app/controllers/clerks_controller.rb', line 18

def new
  @clerk = Clerk.new
  render :edit
end

#showObject



15
16
# File 'app/controllers/clerks_controller.rb', line 15

def show
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/clerks_controller.rb', line 36

def update
  pars = params_for_model
  if pars["password"].blank? and pars["password_confirmation"].blank?
    pars.delete("password")
    pars.delete("password_confirmation")
  end
  if @clerk.update_attributes(pars)
    redirect_to clerk_path(@clerk),  :notice => t(:update_success, :model => "clerk")
  else
    render :action => :edit
  end
end