Class: NippoCore::GroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
# File 'app/controllers/nippo_core/groups_controller.rb', line 17

def create
  if @group.save
    @group.add_member(current_user)
    redirect_to root_path
  else
    render 'new', status: 400
  end
end

#indexObject



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

def index
  @groups = NippoCore::Group.order(created_at: :desc).page(params[:page]).per(10)
end

#newObject



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

def new
end

#showObject



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

def show
  @group = NippoCore::Group.find(params[:id])
  @reports = @group.reports.order(reported_at: :desc).limit(5)
end