crud

作者: Ludiwgbet | 来源:发表于2017-03-23 16:58 被阅读26次

def index
@groups = Group.all
end

def show
@group = Group.find(params[:id])
end

def edit
@group = Group.find(params[:id])
end

def new
@group = Group.new
end

def create
@group = Group.new(group_params)
@group.save

  redirect_to groups_path

end

def update
@group = Group.find(params[:id])

@group.update(group_params)

redirect_to groups_path, notice: "Update Success"

end

def destroy
@group = Group.find(params[:id])
@group.destroy
flash[:alert] = "Group deleted"
redirect_to groups_path
end

private

def group_params
params.require(:group).permit(:title, :description)
end

end

相关文章

网友评论

      本文标题:crud

      本文链接:https://www.haomeiwen.com/subject/jkdtottx.html