Sha256: 4a12875443dfc9a877963b8d1371fd00b00b188b6b6f597b7fc1414f3f9c0ade
Contents?: true
Size: 1.56 KB
Versions: 13
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true require_dependency "think_feel_do_engine/application_controller" module ThinkFeelDoEngine module Coach # Manage messages from the site to Participants. class SiteMessagesController < ApplicationController before_action :authenticate_user!, :set_group load_and_authorize_resource except: [:index] def index authorize! :index, SiteMessage participant_ids = current_user.participants_for_group(@group).ids @site_messages = SiteMessage .where(participant_id: participant_ids) end def show end def new set_participants redirect_to(coach_group_site_messages_path(@group), alert: "A group must have participants in order "\ " to send site message.") if @participants.empty? end def create if @site_message.save SiteMessageMailer.general(@site_message).deliver_now redirect_to coach_group_site_message_path(@group, @site_message), notice: "Site message was successfully created." else set_participants render :new end end private def site_message_params params .require(:site_message) .permit( :participant_id, :subject, :body ) end def set_group @group = Group.find(params[:group_id]) end def set_participants @participants = current_user.participants_for_group(@group) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems