trustieforge/app/controllers/notificationcomments_contro...

37 lines
1.4 KiB
Ruby

class NotificationcommentsController < ApplicationController
def show
end
# default_search_scope :contestnotifications
# model_object Contestnotifications
# before_filter :authorize
def create
#raise Unauthorized unless @contestnotifications.notificationcommentable?
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
# @notificaioncomment = Notificationcomment.new
# @notificaioncomment.safe_attributes = params[:notificationcomment]
# @notificaioncomment.author = User.current
comment = @contestnotification.notificationcomments.new(params[:notificationcomment].merge(author_id: User.current.id))
if comment.save
flash[:notice] = l(:label_comment_added)
end
redirect_to contest_contestnotification_url(@contest, @contestnotification)
end
def destroy
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
notificaioncomments = Notificationcomment.find(params[:id])
notificaioncomments.destroy if notificaioncomments
#@contestnotifications = notificaioncomments.Contestnotification
#@contest = @contestnotifications.contest
#@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
redirect_to contest_contestnotification_url(@contest,@contestnotification)
end
end