Files
danbooru/app/controllers/comments_controller.rb
albert 5610731b35 sync
2010-08-18 18:42:33 -04:00

29 lines
729 B
Ruby

class CommentsController < ApplicationController
respond_to :html, :xml, :json
def index
@posts = Post.paginate :order => "last_commented_at DESC", :per_page => 8
end
def update
@comment = Comment.find(params[:id])
@comment.update_attributes(params[:comment])
respond_with(@comment)
end
def create
@comment = Comment.new(params[:comment])
@comment.post_id = params[:comment][:post_id]
@comment.creator_id = @current_user.id
@comment.ip_addr = request.remote_ip
@comment.score = 0
@comment.save
respond_with(@comment) do |format|
format.html do
flash[:notice] = "Comment posted"
redirect_to posts_path(@comment.post)
end
end
end
end