Created
April 3, 2017 06:10
-
-
Save blueming/6263b266bce8b8c06c30e9355211e631 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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