This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
tuxbliki/app/controllers/comments.rb

38 lines
934 B
Ruby
Raw Normal View History

2008-06-27 00:13:15 -04:00
class Comments < Application
2008-08-28 19:36:31 -04:00
include Ambethia::ReCaptcha::Controller
2008-06-27 00:13:15 -04:00
def new
only_provides :html
@page = Page.find_by_name(params[:page_id].gsub(/_/, ' '))
raise NotFound unless @page
@comment = Comment.new
render
end
def create
@page = Page.find_by_name(params[:page_id].gsub(/_/, ' '))
raise NotFound unless @page
@comment = Comment.new(params[:comment])
@comment.page_id = @page.id
2008-08-28 19:36:31 -04:00
if (logged_in? or verify_recaptcha(@comment)) and @comment.save
2008-06-27 00:13:15 -04:00
flash[:notice] = 'Great success!'
redirect url(:page, :id => params[:page_id])
else
render :new
end
end
def delete
@comment = Comment.find(params[:id])
raise NotFound unless @comment
@page = @comment.page
2008-07-03 02:34:58 -04:00
if @comment.destroy
2008-06-27 00:13:15 -04:00
flash[:notice] = 'Comment was destroyed.'
redirect url(:page, :id => @page.name.gsub(/ /, '_'))
else
raise BadRequest
end
end
end