Sha256: 66ad0e5148541341c707be7c5a02bb525a0ea3b79bbf87d3100f672039eddac8
Contents?: true
Size: 752 Bytes
Versions: 13
Compression:
Stored size: 752 Bytes
Contents
# encoding: utf-8 module Dorsale class CommentsController < ApplicationController def create if defined?(current_user) && current_user.present? @comment = current_user.comments.new(comment_params) else @comment = Comment.new(comment_params) end if @comment.save flash[:success] = "Comment was successfully created." else flash[:danger] = "Error : comment not saved." end redirect_to params[:back_url] || request.referer || main_app.root_path end private def permitted_params [:commentable_id, :commentable_type, :text] end def comment_params params.require(:comment).permit(permitted_params) end end end
Version data entries
13 entries across 13 versions & 1 rubygems