Skip to content

Instantly share code, notes, and snippets.

@blueming
Created April 3, 2017 06:10
Show Gist options
  • Save blueming/6263b266bce8b8c06c30e9355211e631 to your computer and use it in GitHub Desktop.
Save blueming/6263b266bce8b8c06c30e9355211e631 to your computer and use it in GitHub Desktop.
class GroupsController < ApplicationController
def index
@groups = Group.all
end
def new
@groups = Group.new
end
def show
@groups = Group.find(params[:id])
end
def edit
@groups = Group.fing(params[:id])
end
def create
@groups = Group.new(group_params)
if groups.save
redirect_to groups_path
else
render:new
end
end
def update
@groups = Group.find(params[:id])
if @group.update(group_params)
redirect_to groups_path, notice: 'Update Success'
else
render :edit
end
end
def destroy
@goup = Group.find(params[:id])
group.destroy
redirect_to groups_path, alert: 'Group Deleted'
end
private
def group_params
params.requier(:group).permit(:tital, :description)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment