Sha256: ac07e4b095e9bf8a837415367c0aa2641da8f28c18ecee076ef2361f4d14db61

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

class CommentsController < ApplicationController
  before_filter :get_archive_months, :only => :create
  before_filter :get_post_categories, :only => :create

  def create
     params[:comment].merge!({:user_ip => request.remote_ip, :user_agent => request.env['HTTP_USER_AGENT'], :referrer => request.env['HTTP_REFERER']})
     @comment = Comment.new(params[:comment])
     if @comment.save
       flash[:notice] = "Your comment was submitted successfully."
       flash[:notice] += "  It is awaiting moderation and will be posted soon." if !@comment.approved
       flash[:notice] += " <a href='#comment-#{@comment.id}'>Jump to it now.</a>" if @comment.approved
       session[:comment] = ""
       session[:comment_errors] = ""
       redirect_to @comment.referrer and return false
     else
       flash[:warning] = "There was a problem adding your comment. Check the comment form for more details."
       session[:comment] = params[:comment]
       session[:comment_errors] = @comment.error_message
       redirect_to @comment.referrer
     end
   end

   def destroy
     @comment = Comment.find(params[:comment_id])
     if logged_in? && current_user.staff?
       @comment.destroy
       flash[:notice] = "Comment deleted successfully."
     end
     redirect_to @comment.referrer
   end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.9 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.8 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.7 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.6 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.5 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.4 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.3 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.2 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.1 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.1.0 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.0.18 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.0.17 lib/forge/app/controllers/comments_controller.rb
forge-cli-0.0.16 lib/forge/app/controllers/comments_controller.rb