Sha256: d5ce990f834c0bd6f1c283a30ccf0a5b00b86d0a13cb1eb3d3ae1d4c86820325
Contents?: true
Size: 1.33 KB
Versions: 14
Compression:
Stored size: 1.33 KB
Contents
class CommentsController < ApplicationController before_action :set_comment, only: [:destroy] # POST /comments def create @comment = Comment.new(comment_params) @comment.user = current_user if @comment.save @comment.notify_now :users, key: 'comment.create', parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title } # @comment.notify_later :users, key: 'comment.create', parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title } # @comment.notify :users, key: 'comment.create', notify_later: true, parameters: { notifier_name: @comment.user.printable_notifier_name, article_title: @comment.article.title } redirect_to @comment.article, notice: 'Comment was successfully created.' else redirect_to @comment.article end end # DELETE /comments/1 def destroy article = @comment.article @comment.destroy redirect_to article, notice: 'Comment was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_comment @comment = Comment.find(params[:id]) end # Only allow a trusted parameter "white list" through. def comment_params params.require(:comment).permit(:article_id, :body) end end
Version data entries
14 entries across 14 versions & 1 rubygems