public
Created

Controller

  • Download Gist
group_controller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
class GroupsController < ApplicationController
 
def index
@groups = Group.all
end
def show
@group = Group.find(params[:id])
#@posts = @group.posts
end
 
 
 
def new
@group = Group.new
 
end
 
def edit
@group = Group.find(params[:id])
end
 
def update
@group = Group.find(params[:id])
 
if @group.update(group_params)
redirect_to group_path(@group)
else
render :edit
end
end
 
def create
 
@group = Group.new(group_params)
 
if @group.save
#flash[:notice] = group_params
redirect_to groups_path
else
#flash[:notice] = "failed"
render :new
end
 
#redirect_to groups_path
end
 
def destroy
@group = Group.find(pa)
end
 
 
 
def destroy
@group = Group.find(params[:id])
@group.destroy
redirect_to groups_path
end
 
private
 
def group_params
 
params.require(:group).permit(:title, :description)
 
end
 
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.