You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: memberships_controller.rb
    path of file: ./repos/ifme/app/controllers/groups
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Groups
  class MembershipsController < ApplicationController
    before_action :authenticate_user!

    # POST /groups/:group_id/membership
    def create
      @group_member = GroupMember.create!(group_member_params)
      @group = @group_member.group
      GroupNotifier
    
    def create
      @group_member = GroupMember.create!(group_member_params)
      @group = @group_member.group
      GroupNotifier.new(@group, 'new_group_member', current_user)
                   .send_notifications_to(@group.leaders)

      flash[:notice] = t('groups.join.success')
      redirect_to_group
    rescue StandardError
      flash[:alert] = t('groups.join.group_not_exists')
      redirect_to groups_path
    end