socialforge/app/controllers/notificationcomments_contro...

28 lines
1.0 KiB
Ruby
Raw Normal View History

2014-06-05 10:28:36 +08:00
class NotificationcommentsController < ApplicationController
2014-06-07 10:02:00 +08:00
# default_search_scope :contestnotifications
# model_object Contestnotifications
# before_filter :authorize
2014-06-05 10:28:36 +08:00
def create
2014-06-07 09:22:13 +08:00
#raise Unauthorized unless @contestnotifications.notificationcommentable?
2014-06-07 10:02:00 +08:00
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
2014-06-05 10:28:36 +08:00
2014-06-07 10:45:57 +08:00
# @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)
2014-06-05 10:28:36 +08:00
end
2014-06-07 10:02:00 +08:00
redirect_to contest_contestnotification_path(@contest, @contestnotification)
2014-06-05 10:28:36 +08:00
end
def destroy
2014-06-07 10:02:00 +08:00
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
2014-06-05 10:28:36 +08:00
redirect_to contest_contestnotification_path(@contestnotifications)
end
end