Sha256: fa4201f0d28eee0856451ebc80c1149938f2ab4efebda37e0da30b8d1e245251
Contents?: true
Size: 802 Bytes
Versions: 66
Compression:
Stored size: 802 Bytes
Contents
class DiscussionsMessagesController < AjaxController before_action :set_discussion!, only: [:create, :destroy] before_action :authorize_user!, only: [:destroy, :approve] def create @discussion.submit_message! message_params, current_user redirect_back(fallback_location: root_path) end def destroy current_message.destroy! redirect_back(fallback_location: root_path) end def approve current_message.toggle_approved! head :ok end private def set_discussion! @discussion ||= Discussion.find_by(id: params[:discussion_id]) end def authorize_user! current_message.authorize! current_user end def current_message @message ||= Message.find(params[:id]) end def message_params params.require(:message).permit(:content) end end
Version data entries
66 entries across 66 versions & 1 rubygems