added comment edit
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
before_filter :member_only, :only => [:update, :create]
|
before_filter :member_only, :only => [:update, :create, :edit]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:group_by] == "post"
|
if params[:group_by] == "post"
|
||||||
@@ -13,7 +13,7 @@ class CommentsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
@comment.update_attributes(params[:comment])
|
@comment.update_attributes(params[:comment])
|
||||||
respond_with(@comment)
|
respond_with(@comment, :location => post_path(@comment.post_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -28,6 +28,11 @@ class CommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@comment = Comment.find(params[:id])
|
||||||
|
respond_with(@comment)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def index_by_post
|
def index_by_post
|
||||||
@posts = Post.tag_match(params[:tags]).commented_before(params[:before_date] || Time.now).limit(8)
|
@posts = Post.tag_match(params[:tags]).commented_before(params[:before_date] || Time.now).limit(8)
|
||||||
|
|||||||
11
app/views/comments/edit.html.erb
Normal file
11
app/views/comments/edit.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<div id="c-comments">
|
||||||
|
<div id="a-edit">
|
||||||
|
<h1>Edit Comment</h1>
|
||||||
|
|
||||||
|
<%= simple_form_for(@comment) do |f| %>
|
||||||
|
<%= f.input :body %>
|
||||||
|
<%= f.button :submit %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
<li><span class="link">Reply</span></li>
|
<li><span class="link">Reply</span></li>
|
||||||
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
|
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
|
||||||
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>
|
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>
|
||||||
|
<li><%= link_to "Edit", edit_comment_path(comment.id) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
<li><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
||||||
<li><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
<li><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user