Class: GroupsController

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

Instance Method Summary collapse

Methods included from Zena::App

included

Instance Method Details

#createObject



30
31
32
# File 'app/controllers/groups_controller.rb', line 30

def create
  @group = Group.create(params[:group])
end

#destroyObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/groups_controller.rb', line 51

def destroy
  @group.destroy

  respond_to do |format|
    format.html do
      if @group.errors.empty?
        redirect_to :action => 'index'
      else
        get_users
        get_groups # all groups are used by 'replace_by'
        render :action => 'edit'
      end
    end
    format.js   do
      render(:partial => 'form') unless @group.errors.empty?
    end
    format.xml  { head :ok }
  end
end

#editObject



13
14
15
16
17
18
# File 'app/controllers/groups_controller.rb', line 13

def edit
  respond_to do |format|
    format.html
    format.js { render :partial => 'form' }
  end
end

#indexObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/groups_controller.rb', line 20

def index
  secure(Group) do
    @groups = Group.paginate(:all, :order => 'name', :per_page => 20, :page => params[:page])
  end
  @group = Group.new
  respond_to do |format|
    format.html
  end
end

#showObject



10
11
# File 'app/controllers/groups_controller.rb', line 10

def show
end

#updateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/groups_controller.rb', line 34

def update
  @group.update_attributes(params[:group])

  respond_to do |format|
    format.html do
      if @group.errors.empty?
        redirect_to :action => 'show'
      else
        get_users
        get_groups
        render :action => 'edit'
      end
    end
    format.js { render :action => 'show' }
  end
end