foodsoft/app/controllers/invites_controller.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

36 lines
870 B
Ruby

class InvitesController < ApplicationController
before_action :authenticate_membership_or_admin_for_invites
before_action -> { require_config_disabled :disable_invite }
def new
@invite = Invite.new(user: @current_user, group: @group)
end
def create
authenticate_membership_or_admin params[:invite][:group_id]
@invite = Invite.new(params[:invite])
if @invite.save
Mailer.invite(@invite).deliver_now
respond_to do |format|
format.html do
redirect_to root_path, notice: I18n.t('invites.success')
end
format.js { render layout: false }
end
else
render action: :new
end
end
protected
def authenticate_membership_or_admin_for_invites
authenticate_membership_or_admin(begin
params[:invite][:group_id]
rescue StandardError
params[:id]
end)
end
end