Sha256: d9ebf8016c1164a61ae8721367df4599150872a3ca27a5b8d344f994b03e999c
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module NippoCore class GroupsController < ApplicationController include Pundit before_action :initialize_group, only: [:new, :create] before_action :find_group, except: [:index, :new, :create] def index @groups = NippoCore::Group.order(created_at: :desc).page(params[:page]).per(10) end def new end def show @reports = @group.reports.order(reported_at: :desc).limit(5) @requests = @group.unaccepted_requests.limit(5) @members = @group.members end def create if @group.save current_user.add_member(current_user, @group) redirect_to root_path else render 'new', status: 400 end end def edit authorize @group render layout: nil end def update authorize @group if @group.update(group_params) redirect_to @group else head 400 end end def request_join result = current_user.send_request(@group) render layout: nil end private def initialize_group @group = NippoCore::Group.new(group_params.merge(creator: current_user)) end def group_params params.fetch(:group, {}).permit(:name, :description) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nippo_core-1.0.1 | app/controllers/nippo_core/groups_controller.rb |