diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index d8b808b..52d2615 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -6,5 +6,36 @@ def index def show; end - def new; end + def new + @group = Group.new( + user: current_user + ) + + respond_to do |format| + format.html do + render 'new' + end + end + end + + def create + @group = Group.new(group_params) + @group.user = current_user + + respond_to do |format| + format.html do + if @group.save + redirect_to groups_path + else + render 'new' + end + end + end + end + + private + + def group_params + params.require(:group).permit(:name, :icon) + end end