This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
2008-06-27 00:13:15 -04:00
|
|
|
class Comments < Application
|
|
|
|
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
|
|
|
|
if @comment.save
|
|
|
|
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
|