Class: Socializer::GroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/socializer/groups_controller.rb', line 41

def create
  @group = current_user.groups.build(params[:group])

  if @group.save
    redirect_to @group
  else
    render :new
  end
end

#destroyObject



59
60
61
62
# File 'app/controllers/socializer/groups_controller.rb', line 59

def destroy
  @group.destroy
  redirect_to groups_path
end

#editObject



51
52
# File 'app/controllers/socializer/groups_controller.rb', line 51

def edit
end

#indexObject



5
6
# File 'app/controllers/socializer/groups_controller.rb', line 5

def index
end

#joinableObject



16
17
18
# File 'app/controllers/socializer/groups_controller.rb', line 16

def joinable
  @groups = Socializer::Group.joinable
end

#membershipsObject



20
21
22
# File 'app/controllers/socializer/groups_controller.rb', line 20

def memberships
  @memberships = current_user.memberships
end

#newObject



37
38
39
# File 'app/controllers/socializer/groups_controller.rb', line 37

def new
  @group = Group.new
end

#ownershipsObject



24
25
26
# File 'app/controllers/socializer/groups_controller.rb', line 24

def ownerships
  @ownerships = current_user.groups
end

#pending_invitesObject



28
29
30
# File 'app/controllers/socializer/groups_controller.rb', line 28

def pending_invites
  @pending_invites = current_user.pending_memberships_invites
end

#publicObject



8
9
10
# File 'app/controllers/socializer/groups_controller.rb', line 8

def public
  @groups = Socializer::Group.public
end

#restrictedObject



12
13
14
# File 'app/controllers/socializer/groups_controller.rb', line 12

def restricted
  @groups = Socializer::Group.restricted
end

#showObject



32
33
34
35
# File 'app/controllers/socializer/groups_controller.rb', line 32

def show
  @group = Group.find(params[:id])
  @membership = Membership.find_by(group_id: @group.id)
end

#updateObject



54
55
56
57
# File 'app/controllers/socializer/groups_controller.rb', line 54

def update
  @group.update!(params[:group])
  redirect_to @group
end