Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added comment edit

  • Loading branch information...
commit 187755276e77aa8db8faee64cebeec8f5d853f55 1 parent e352d21
@micahbrich authored
View
20 app/controllers/comments_controller.rb
@@ -17,7 +17,6 @@ def new
end
-
# POST /comments
# POST /comments.xml
def create
@@ -53,6 +52,25 @@ def create
end
+ def edit
+ @comment = @post.comments.find(params[:id])
+ end
+
+ def update
+ @comment = @post.comments.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ flash[:notice] = '@post.comments was successfully updated.'
+ format.html { redirect_to(@post) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
# DELETE /comments/1
# DELETE /comments/1.xml
def destroy
View
3  app/views/comments/edit.html.erb
@@ -0,0 +1,3 @@
+<% @title = "- episode ##{@post.id} - #{@post.title}" %>
+
+<%= render :partial => 'comments/form' %>
View
2  app/views/posts/_post.html.erb
@@ -26,7 +26,7 @@
<% end %>
<% if admin? %>
- <p><small><%= link_to 'Delete', post_comment_path(@post, comment), :method => :delete, :confirm => 'Are you sure?' %></small></p>
+ <p><small><%= link_to 'Edit', edit_post_comment_path(@post, comment) %> | <%= link_to 'Delete', post_comment_path(@post, comment), :method => :delete, :confirm => 'Are you sure?' %></small></p>
<% end %>
<%= textilize(comment.body) %>
View
1  config/environment.rb
@@ -6,6 +6,7 @@
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION
+#RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
View
0  tmp/restart.txt
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.