5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/forge/app/controllers/comments_controller.rb', line 5
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
|