Class: GroupsController
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
in_place_edit_for
#l, load_localized_strings, #valid_language?
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/groups_controller.rb', line 19
def create
@group = Group.new(params[:group])
if @group.save
flash[:notice] = 'Group was successfully created.'
back_or_redirect_to :action => 'list'
else
render :action => 'new'
end
end
|
#destroy ⇒ Object
46
47
48
49
|
# File 'app/controllers/groups_controller.rb', line 46
def destroy
Group.find(params[:id]).destroy
redirect_to :action => 'list'
end
|
#edit ⇒ Object
29
30
31
32
33
34
|
# File 'app/controllers/groups_controller.rb', line 29
def edit
@group = Group.find(params[:id])
@users = User.find(:all)
@members = @group.users.to_s
@groups = Group.find(:all, :order => 'name')
end
|
#index ⇒ Object
2
3
4
5
|
# File 'app/controllers/groups_controller.rb', line 2
def index
list
render :action => 'list'
end
|
#list ⇒ Object
11
12
13
|
# File 'app/controllers/groups_controller.rb', line 11
def list
@group_pages, @groups = paginate :groups, :per_page => 10
end
|
#new ⇒ Object
15
16
17
|
# File 'app/controllers/groups_controller.rb', line 15
def new
@group = Group.new
end
|
#set_member ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/groups_controller.rb', line 51
def set_member
@group = Group.find(params[:id])
@user = User.find(params[:user_id])
if params[:value] == 'true'
@group.users << @user unless @group.users.include? @user
else
@group.users.delete @user
end
@users = User.find(:all)
redirect_to :action => :edit, :id => @group
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/groups_controller.rb', line 36
def update
@group = Group.find(params[:id])
if @group.update_attributes(params[:group])
flash[:notice] = 'Group was successfully updated.'
back_or_redirect_to :action => :edit, :id => @group
else
render :action => 'edit'
end
end
|