Skip to content

@poc7667 /group_controller
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Controller
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.