Skip to content

Commit

Permalink
add Group actions for New and create, and permit name and icons as pa…
Browse files Browse the repository at this point in the history
…rameters
  • Loading branch information
Diegogagan2587 committed Oct 26, 2023
1 parent aae091b commit 00ef791
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 00ef791

Please sign in to comment.