Class: Detour::GroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/detour/groups_controller.rb', line 10

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

  if @group.save
    flash[:notice] = "Your group has been successfully created."
    render "detour/shared/success"
  else
    @model = @group
    render "detour/shared/error"
  end
end

#destroyObject



33
34
35
36
37
38
# File 'app/controllers/detour/groups_controller.rb', line 33

def destroy
  @group = Detour::Group.find(params[:id])
  @group.destroy
  flash[:notice] = "Group \"#{@group.name}\" has been deleted."
  redirect_to groups_path
end

#indexObject



2
3
4
# File 'app/controllers/detour/groups_controller.rb', line 2

def index
  @groups = Detour::Group.all
end

#showObject



6
7
8
# File 'app/controllers/detour/groups_controller.rb', line 6

def show
  @group = Detour::Group.find(params[:id])
end

#updateObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/detour/groups_controller.rb', line 22

def update
  @group = Detour::Group.find(params[:id])

  if @group.update_attributes(params[:group])
    flash[:notice] = "Your group has been successfully updated."
    redirect_to group_path @group
  else
    render :show
  end
end